diff --git a/source/timemory/utility/argparse.hpp b/source/timemory/utility/argparse.hpp index e552fa8f7..0e090900c 100644 --- a/source/timemory/utility/argparse.hpp +++ b/source/timemory/utility/argparse.hpp @@ -458,11 +458,31 @@ struct argument_parser return *this; } - argument& required(bool req, std::string _msg = "") + template + argument& required(std::initializer_list&& _v) + { + container_append(m_requires, std::vector{ _v }); + return *this; + } + + template + argument& required(Tp&& _v, std::string_view _msg = {}) { - m_required = req; - m_required_info = - (_msg.empty()) ? "" : std::string{ " :: " } + std::move(_msg); + using core_type = concepts::unqualified_type_t; + if constexpr(std::is_same::value) + { + m_required = _v; + } + else + { + static_assert(helpers::is_initializing_container::value, + "Error! Expected a container or initializer_list"); + container_append(m_requires, std::forward(_v)); + } + + if(!_msg.empty()) + m_required_info += std::string{ " :: " } + std::string{ _msg }; + return *this; } @@ -572,22 +592,6 @@ struct argument_parser return *this; } - template - argument& required(std::initializer_list&& _v) - { - container_append(m_requires, std::vector{ _v }); - return *this; - } - - template - argument& required(Tp&& _v) - { - static_assert(helpers::is_initializing_container::value, - "Error! Expected a container or initializer_list"); - container_append(m_requires, std::forward(_v)); - return *this; - } - template argument& action(ActionFuncT&& _func) {