diff --git a/include/clipp.h b/include/clipp.h index d7b101e..efda1fa 100644 --- a/include/clipp.h +++ b/include/clipp.h @@ -45,7 +45,7 @@ #include #include #include - +#include /*************************************************************************//** * @@ -160,7 +160,7 @@ constexpr auto check_is_callable(int) -> decltype( std::declval()(std::declval()...), std::integral_constant::type>::value>{} ); + std::is_same_v>>{} ); template constexpr auto @@ -171,7 +171,7 @@ constexpr auto check_is_callable_without_arg(int) -> decltype( std::declval()(), std::integral_constant::type>::value>{} ); + std::is_same_v>>{} ); template constexpr auto @@ -350,7 +350,7 @@ inline T clamped_on_limits(const V& v) { template struct make { static inline T from(const char* s) { - if(!s) return false; + if(!s) return T{}; //a conversion from const char* to / must exist return static_cast(s); } @@ -6563,7 +6563,7 @@ class documentation doc_formatting usgFmt_; filter_function filter_; enum class paragraph { param, group }; - + mutable std::unordered_set printed_param_keys_; /***************************************************************//** * @@ -6578,6 +6578,7 @@ class documentation fos.hanging_indent(0); fos.paragraph_spacing(0); fos.ignore_newline_chars(fmt_.ignore_newline_chars()); + printed_param_keys_.clear(); print_doc(fos, cli_); } @@ -6637,9 +6638,17 @@ class documentation else { const auto& p = ptrn.as_param(); if(!filter_(p)) return; + + auto label = param_label(p, fmt_); + std::string key = label.c_str(); + key += p.doc(); + + if (!printed_param_keys_.insert(key).second) { + return; + } handle_spacing(os, paragraph::param, indentLvl); - print_entry(os, param_label(p, fmt_), p.doc()); + print_entry(os, label, p.doc()); } }