From 4c5ded8c849de94f3d2d2d6e6f4e6e0605d7e3be Mon Sep 17 00:00:00 2001 From: Zhihao Yuan Date: Sun, 17 Nov 2019 18:55:52 -0600 Subject: [PATCH] Constrain Argument constructor better Without this change, std::allocator can construct Argument --- include/argparse.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/argparse.hpp b/include/argparse.hpp index d06ec35..4498462 100644 --- a/include/argparse.hpp +++ b/include/argparse.hpp @@ -69,6 +69,11 @@ struct is_container< template static constexpr bool is_container_v = is_container::value; +template +struct is_string_like + : std::conjunction, + std::is_convertible> {}; + template using enable_if_container = std::enable_if_t, T>; @@ -115,8 +120,7 @@ public: template ...>, - int> = 0> + std::conjunction_v...>, int> = 0> explicit Argument(Args &&... args) : Argument({std::string(std::forward(args))...}, std::make_index_sequence{}) {}