From bef238b6590167d6cc68f2f6a582cb1a9e7434c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Musia=C5=82?= <111433005+SpectraL519@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:58:54 +0100 Subject: [PATCH] removed redundant inline modifiers for member functions --- include/ap/argument_parser.hpp | 104 ++++++++++++++++----------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/include/ap/argument_parser.hpp b/include/ap/argument_parser.hpp index 1cd2c05..11c1df7 100644 --- a/include/ap/argument_parser.hpp +++ b/include/ap/argument_parser.hpp @@ -147,7 +147,7 @@ class range { ~range() = default; /// @return True if the range is [1, 1]. - [[nodiscard]] inline bool is_default() const { + [[nodiscard]] bool is_default() const { return this->_default; } @@ -350,7 +350,7 @@ struct argument_name { * @param other The argument_name instance to compare with. * @return Equality of argument names. */ - inline bool operator==(const argument_name& other) const { + bool operator==(const argument_name& other) const { return this->primary == other.primary; } @@ -359,12 +359,12 @@ struct argument_name { * @param name The string view to compare with. * @return Equality of names comparison (either primary or secondary name). */ - inline bool operator==(std::string_view name) const { + bool operator==(std::string_view name) const { return name == this->primary or (this->secondary and name == this->secondary.value()); } /// @brief Get a string representation of the argument_name. - [[nodiscard]] inline std::string str() const { + [[nodiscard]] std::string str() const { return this->secondary ? ("[" + this->primary + "," + this->secondary.value() + "]") : ("[" + this->primary + "]"); @@ -639,7 +639,7 @@ class positional_argument : public detail::argument_interface { * @param other Another positional_argument for comparison. * @return Result of equality */ - inline bool operator==(const positional_argument& other) const { + bool operator==(const positional_argument& other) const { return this->_name == other._name; } @@ -648,7 +648,7 @@ class positional_argument : public detail::argument_interface { * @param help_msg The help message to set. * @return Reference to the positional_argument. */ - inline positional_argument& help(std::string_view help_msg) override { + positional_argument& help(std::string_view help_msg) override { this->_help_msg = help_msg; return *this; } @@ -659,7 +659,7 @@ class positional_argument : public detail::argument_interface { * @return Reference to the positional_argument. * @note Requires T to be equality comparable. */ - inline positional_argument& choices(const std::vector& choices) + positional_argument& choices(const std::vector& choices) requires(utility::equality_comparable) { this->_choices = choices; @@ -674,14 +674,14 @@ class positional_argument : public detail::argument_interface { * @return Reference to the positional_argument. */ template F> - inline positional_argument& action(F&& action) { + positional_argument& action(F&& action) { using callable_type = ap::action::detail::callable_type; this->_action = std::forward(action); return *this; } /// @return True if the positional argument is optional., false if required. - [[nodiscard]] inline bool is_optional() const override { + [[nodiscard]] bool is_optional() const override { return this->_optional; } @@ -698,22 +698,22 @@ class positional_argument : public detail::argument_interface { private: /// @return Reference the name of the positional argument. - [[nodiscard]] inline const detail::argument_name& name() const override { + [[nodiscard]] const detail::argument_name& name() const override { return this->_name; } /// @return Optional help message for the positional argument. - [[nodiscard]] inline const std::optional& help() const override { + [[nodiscard]] const std::optional& help() const override { return this->_help_msg; } /// @return True if the positional argument is required, false otherwise - [[nodiscard]] inline bool is_required() const override { + [[nodiscard]] bool is_required() const override { return this->_required; } /// @return True if bypassing the required status is enabled for the positional argument, false otherwise. - [[nodiscard]] inline bool bypass_required_enabled() const override { + [[nodiscard]] bool bypass_required_enabled() const override { return this->_bypass_required; } @@ -724,12 +724,12 @@ class positional_argument : public detail::argument_interface { void set_used() override {} /// @return True if the positional argument is used, false otherwise. - [[nodiscard]] inline bool is_used() const override { + [[nodiscard]] bool is_used() const override { return this->_value.has_value(); } /// @return The number of times the positional argument is used. - [[nodiscard]] inline std::size_t nused() const override { + [[nodiscard]] std::size_t nused() const override { return static_cast(this->_value.has_value()); } @@ -759,27 +759,27 @@ class positional_argument : public detail::argument_interface { } /// @return True if the positional argument has a value, false otherwise. - [[nodiscard]] inline bool has_value() const override { + [[nodiscard]] bool has_value() const override { return this->_value.has_value(); } /// @return True if the positional argument has parsed values, false otherwise. - [[nodiscard]] inline bool has_parsed_values() const override { + [[nodiscard]] bool has_parsed_values() const override { return this->_value.has_value(); } /// @return Ordering relationship of positional argument range. - [[nodiscard]] inline std::weak_ordering nvalues_in_range() const override { + [[nodiscard]] std::weak_ordering nvalues_in_range() const override { return this->_value.has_value() ? std::weak_ordering::equivalent : std::weak_ordering::less; } /// @brief Get the stored value of the positional argument. - [[nodiscard]] inline const std::any& value() const override { + [[nodiscard]] const std::any& value() const override { return this->_value; } /// @return Reference to the vector of parsed values for the positional argument. - [[nodiscard]] inline const std::vector& values() const override { + [[nodiscard]] const std::vector& values() const override { throw std::logic_error("Positional argument " + this->_name.primary + "has only 1 value."); } @@ -788,7 +788,7 @@ class positional_argument : public detail::argument_interface { * @param choice The value to check against choices. * @return True if the choice valid, false otherwise. */ - [[nodiscard]] inline bool _is_valid_choice(const value_type& choice) const { + [[nodiscard]] bool _is_valid_choice(const value_type& choice) const { return this->_choices.empty() or std::ranges::find(this->_choices, choice) != this->_choices.end(); } @@ -856,7 +856,7 @@ class optional_argument : public detail::argument_interface { * @param other The optional_argument to compare with. * @return Equality of comparison. */ - inline bool operator==(const optional_argument& other) const { + bool operator==(const optional_argument& other) const { return this->_name == other._name; } @@ -865,7 +865,7 @@ class optional_argument : public detail::argument_interface { * @param help_msg The help message to set. * @return Reference to the optional_argument. */ - inline optional_argument& help(std::string_view help_msg) override { + optional_argument& help(std::string_view help_msg) override { this->_help_msg = help_msg; return *this; } @@ -874,7 +874,7 @@ class optional_argument : public detail::argument_interface { * @brief Mark the optional argument as required. * @return Reference to the optional_argument. */ - inline optional_argument& required() { + optional_argument& required() { this->_required = true; return *this; } @@ -883,7 +883,7 @@ class optional_argument : public detail::argument_interface { * @brief Enable bypassing the required status for the optional argument. * @return Reference to the optional_argument. */ - inline optional_argument& bypass_required() { + optional_argument& bypass_required() { this->_bypass_required = true; return *this; } @@ -893,7 +893,7 @@ class optional_argument : public detail::argument_interface { * @param range The nargs range to set. * @return Reference to the optional_argument. */ - inline optional_argument& nargs(const ap::nargs::range& range) { + optional_argument& nargs(const ap::nargs::range& range) { this->_nargs_range = range; return *this; } @@ -903,7 +903,7 @@ class optional_argument : public detail::argument_interface { * @param count The count for nargs range. * @return Reference to the optional_argument. */ - inline optional_argument& nargs(const count_type count) { + optional_argument& nargs(const count_type count) { this->_nargs_range = ap::nargs::range(count); return *this; } @@ -914,7 +914,7 @@ class optional_argument : public detail::argument_interface { * @param nhigh The upper bound for nargs range. * @return Reference to the optional_argument. */ - inline optional_argument& nargs(const count_type nlow, const count_type nhigh) { + optional_argument& nargs(const count_type nlow, const count_type nhigh) { this->_nargs_range = ap::nargs::range(nlow, nhigh); return *this; } @@ -927,7 +927,7 @@ class optional_argument : public detail::argument_interface { * @return Reference to the optional_argument. */ template F> - inline optional_argument& action(F&& action) { + optional_argument& action(F&& action) { using callable_type = ap::action::detail::callable_type; this->_action = std::forward(action); return *this; @@ -939,7 +939,7 @@ class optional_argument : public detail::argument_interface { * @return Reference to the optional_argument. * @note Requires T to be equality comparable. */ - inline optional_argument& choices(const std::vector& choices) + optional_argument& choices(const std::vector& choices) requires(utility::equality_comparable) { this->_choices = choices; @@ -967,7 +967,7 @@ class optional_argument : public detail::argument_interface { } /// @return True if argument is optional, false otherwise. - [[nodiscard]] inline bool is_optional() const override { + [[nodiscard]] bool is_optional() const override { return this->_optional; } @@ -983,22 +983,22 @@ class optional_argument : public detail::argument_interface { private: /// @return Reference to the name of the optional argument. - [[nodiscard]] inline const detail::argument_name& name() const override { + [[nodiscard]] const detail::argument_name& name() const override { return this->_name; } /// @return Reference to the optional help message for the optional argument. - [[nodiscard]] inline const std::optional& help() const override { + [[nodiscard]] const std::optional& help() const override { return this->_help_msg; } /// @return True if the optional argument is required, false otherwise. - [[nodiscard]] inline bool is_required() const override { + [[nodiscard]] bool is_required() const override { return this->_required; } /// @return True if bypassing the required status is enabled for the optional argument, false otherwise. - [[nodiscard]] inline bool bypass_required_enabled() const override { + [[nodiscard]] bool bypass_required_enabled() const override { return this->_bypass_required; } @@ -1008,12 +1008,12 @@ class optional_argument : public detail::argument_interface { } /// @return True if the optional argument is used, false otherwise. - [[nodiscard]] inline bool is_used() const override { + [[nodiscard]] bool is_used() const override { return this->_nused > 0; } /// @return The number of times the optional argument is used. - [[nodiscard]] inline std::size_t nused() const override { + [[nodiscard]] std::size_t nused() const override { return this->_nused; } @@ -1043,12 +1043,12 @@ class optional_argument : public detail::argument_interface { } /// @return True if the optional argument has a value, false otherwise. - [[nodiscard]] inline bool has_value() const override { + [[nodiscard]] bool has_value() const override { return this->has_parsed_values() or this->_has_predefined_value(); } /// @return True if parsed values are available for the optional argument, false otherwise. - [[nodiscard]] inline bool has_parsed_values() const override { + [[nodiscard]] bool has_parsed_values() const override { return not this->_values.empty(); } @@ -1064,22 +1064,22 @@ class optional_argument : public detail::argument_interface { } /// @return Reference to the stored value of the optional argument. - [[nodiscard]] inline const std::any& value() const override { + [[nodiscard]] const std::any& value() const override { return this->_values.empty() ? this->_predefined_value() : this->_values.front(); } /// @return Reference to the vector of parsed values for the optional argument. - [[nodiscard]] inline const std::vector& values() const override { + [[nodiscard]] const std::vector& values() const override { return this->_values; } /// @return True if the optional argument has a predefined value, false otherwise. - [[nodiscard]] inline bool _has_predefined_value() const { + [[nodiscard]] bool _has_predefined_value() const { return this->_default_value.has_value() or (this->is_used() and this->_implicit_value.has_value()); } /// @return Reference to the predefined value of the optional argument. - [[nodiscard]] inline const std::any& _predefined_value() const { + [[nodiscard]] const std::any& _predefined_value() const { return this->is_used() ? this->_implicit_value : this->_default_value; } @@ -1088,7 +1088,7 @@ class optional_argument : public detail::argument_interface { * @param choice The value to check against choices. * @return True if choice is valid, false otherwise. */ - [[nodiscard]] inline bool _is_valid_choice(const value_type& choice) const { + [[nodiscard]] bool _is_valid_choice(const value_type& choice) const { return this->_choices.empty() or std::ranges::find(this->_choices, choice) != this->_choices.end(); } @@ -1156,7 +1156,7 @@ class argument_parser { * @param name The name of the program. * @return Reference to the argument parser. */ - inline argument_parser& program_name(std::string_view name) { + argument_parser& program_name(std::string_view name) { this->_program_name = name; return *this; } @@ -1166,7 +1166,7 @@ class argument_parser { * @param description The description of the program. * @return Reference to the argument parser. */ - inline argument_parser& program_description(std::string_view description) { + argument_parser& program_description(std::string_view description) { this->_program_description = description; return *this; } @@ -1176,7 +1176,7 @@ class argument_parser { * @param args Vector of default positional argument categories. * @return Reference to the argument parser. */ - inline argument_parser& default_positional_arguments(const std::vector& args) { + argument_parser& default_positional_arguments(const std::vector& args) { for (const auto arg : args) this->_add_default_positional_argument(arg); return *this; @@ -1187,7 +1187,7 @@ class argument_parser { * @param args Vector of default optional argument categories. * @return Reference to the argument parser. */ - inline argument_parser& default_optional_arguments(const std::vector& args) { + argument_parser& default_optional_arguments(const std::vector& args) { for (const auto arg : args) this->_add_default_optional_argument(arg); return *this; @@ -1435,7 +1435,7 @@ class argument_parser { * @param other Another cmd_argument to compare with. * @return Boolean statement of equality comparison. */ - inline bool operator==(const cmd_argument& other) const { + bool operator==(const cmd_argument& other) const { return this->discriminator == other.discriminator and this->value == other.value; } @@ -1512,7 +1512,7 @@ class argument_parser { * @param name The name of the argument. * @return Argument predicate based on the provided name. */ - [[nodiscard]] inline argument_predicate_type _name_eq_predicate(const std::string_view& name) const { + [[nodiscard]] argument_predicate_type _name_eq_predicate(const std::string_view& name) const { return [&name](const argument_ptr_type& arg) { return name == arg->name(); }; } @@ -1522,7 +1522,7 @@ class argument_parser { * @param secondary_name The secondary name of the argument. * @return Argument predicate based on the provided name and secondary name. */ - [[nodiscard]] inline argument_predicate_type _name_eq_predicate( + [[nodiscard]] argument_predicate_type _name_eq_predicate( const std::string_view& primary_name, const std::string_view& secondary_name ) const { return [&primary_name, &secondary_name](const argument_ptr_type& arg) { @@ -1682,7 +1682,7 @@ class argument_parser { * @brief Check if optional arguments can bypass the required arguments. * @return True if optional arguments can bypass required arguments, false otherwise. */ - [[nodiscard]] inline bool _bypass_required_args() const { + [[nodiscard]] bool _bypass_required_args() const { return std::ranges::any_of(this->_optional_args, [](const argument_ptr_type& arg) { return arg->is_used() and arg->bypass_required_enabled(); });