From cb2777db6e868fec0f1ea8bece12dc6323bb1f78 Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Mon, 7 Feb 2022 14:33:16 -0700 Subject: [PATCH] Update header source format with clang-format Most changes are to better fit within "ColumnLimit: 80". The change from "T &&... var" to "T &&...var" is caused by "PointerAlignment: Right". Member functions chained from add_argument() use ContinuationIndentWidth, which is set to 4. Setting ContinuationIndentWidth to 2 causes many other continuation lines to change. So, this commit uses the original value (i.e. 4) as the preferred size. Signed-off-by: Sean Robinson --- include/argparse/argparse.hpp | 69 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/include/argparse/argparse.hpp b/include/argparse/argparse.hpp index 9f8cde2..af20f0b 100644 --- a/include/argparse/argparse.hpp +++ b/include/argparse/argparse.hpp @@ -55,17 +55,15 @@ namespace argparse { namespace details { // namespace for helper methods -template -struct is_container : std::false_type {}; +template struct is_container : std::false_type {}; template <> struct is_container : std::false_type {}; template -struct is_container().begin()), - decltype(std::declval().end()), - decltype(std::declval().size())>> - : std::true_type {}; +struct is_container< + T, std::void_t().begin()), + decltype(std::declval().end()), + decltype(std::declval().size())>> : std::true_type {}; template static constexpr bool is_container_v = is_container::value; @@ -74,9 +72,9 @@ template struct is_streamable : std::false_type {}; template -struct is_streamable< - T, std::void_t() << std::declval())>> - : std::true_type {}; +struct is_streamable() + << std::declval())>> + : std::true_type {}; template static constexpr bool is_streamable_v = is_streamable::value; @@ -100,7 +98,8 @@ template std::string repr(T const &val) { out << repr(*val.begin()); std::for_each( std::next(val.begin()), - std::next(val.begin(), std::min(size, repr_max_container_size) - 1), + std::next(val.begin(), + std::min(size, repr_max_container_size) - 1), [&out](const auto &v) { out << " " << repr(v); }); if (size <= repr_max_container_size) { out << " "; @@ -336,8 +335,8 @@ enum class default_arguments : unsigned int { all = help | version, }; -inline default_arguments operator& (const default_arguments &a, - const default_arguments &b) { +inline default_arguments operator&(const default_arguments &a, + const default_arguments &b) { return static_cast( static_cast::type>(a) & static_cast::type>(b)); @@ -390,7 +389,7 @@ public: } template - auto action(F &&aAction, Args &&... aBound) + auto action(F &&aAction, Args &&...aBound) -> std::enable_if_t, Argument &> { using action_type = std::conditional_t< @@ -858,25 +857,25 @@ public: : mProgramName(std::move(aProgramName)), mVersion(std::move(aVersion)) { if ((aArgs & default_arguments::help) == default_arguments::help) { add_argument("-h", "--help") - .action([&](const auto &unused) { - std::cout << help().str(); - std::exit(0); - }) - .default_value(false) - .help("shows help message and exits") - .implicit_value(true) - .nargs(0); + .action([&](const auto &unused) { + std::cout << help().str(); + std::exit(0); + }) + .default_value(false) + .help("shows help message and exits") + .implicit_value(true) + .nargs(0); } if ((aArgs & default_arguments::version) == default_arguments::version) { add_argument("-v", "--version") - .action([&](const auto &unused) { - std::cout << mVersion; - std::exit(0); - }) - .default_value(false) - .help("prints version information and exits") - .implicit_value(true) - .nargs(0); + .action([&](const auto &unused) { + std::cout << mVersion; + std::exit(0); + }) + .default_value(false) + .help("prints version information and exits") + .implicit_value(true) + .nargs(0); } } @@ -891,12 +890,12 @@ public: mIsParsed(other.mIsParsed), mPositionalArguments(other.mPositionalArguments), mOptionalArguments(other.mOptionalArguments) { - for (auto it = std::begin(mPositionalArguments); it != std::end(mPositionalArguments); - ++it) { + for (auto it = std::begin(mPositionalArguments); + it != std::end(mPositionalArguments); ++it) { index_argument(it); } - for (auto it = std::begin(mOptionalArguments); it != std::end(mOptionalArguments); - ++it) { + for (auto it = std::begin(mOptionalArguments); + it != std::end(mOptionalArguments); ++it) { index_argument(it); } } @@ -928,7 +927,7 @@ public: // Parameter packed add_parents method // Accepts a variadic number of ArgumentParser objects template - ArgumentParser &add_parents(const Targs &... Fargs) { + ArgumentParser &add_parents(const Targs &...Fargs) { for (const ArgumentParser &tParentParser : {std::ref(Fargs)...}) { for (const auto &tArgument : tParentParser.mPositionalArguments) { auto it =