Skip to content

Commit

Permalink
Merge pull request #46 from smehringer/std_arihtmetic
Browse files Browse the repository at this point in the history
[MISC] Remove dependency of seqan3::arithmetic by using std::is_arithmetic_v.
  • Loading branch information
eseiler authored Jan 21, 2022
2 parents 1506aa8 + 2936768 commit a3dedd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions include/sharg/detail/format_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ class format_parse : public format_base
}

/*!\brief Tries to parse an input string into an arithmetic value.
* \tparam option_t The option value type; must model seqan3::arithmetic.
* \tparam option_t The option value type; must model std::is_arithmetic_v.
* \param[out] value Stores the parsed value.
* \param[in] in The input argument to be parsed.
* \returns sharg::option_parse_result::error if `in` could not be parsed to an arithmetic type
Expand All @@ -405,9 +405,9 @@ class format_parse : public format_base
*
* This function delegates to std::from_chars.
*/
template <seqan3::arithmetic option_t>
template <typename option_t>
//!\cond
requires seqan3::input_stream_over<std::istringstream, option_t>
requires std::is_arithmetic_v<option_t> && seqan3::input_stream_over<std::istringstream, option_t>
//!\endcond
option_parse_result parse_option_value(option_t & value, std::string const & in)
{
Expand Down Expand Up @@ -467,7 +467,7 @@ class format_parse : public format_base
get_type_name_as_string(option_type{}) + "."};
}

if constexpr (seqan3::arithmetic<option_type>)
if constexpr (std::is_arithmetic_v<option_type>)
{
if (res == option_parse_result::overflow_error)
{
Expand Down
11 changes: 7 additions & 4 deletions include/sharg/validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ concept validator = std::copyable<std::remove_cvref_t<validator_type>> &&
/*!\brief A validator that checks whether a number is inside a given range.
* \ingroup argument_parser
* \implements sharg::validator
* \tparam option_value_t The value type of the range; must model seqan3::arithmetic .
* \tparam option_value_t The value type of the range; must model std::is_arithmetic_v.
*
* \details
*
Expand All @@ -69,7 +69,10 @@ concept validator = std::copyable<std::remove_cvref_t<validator_type>> &&
*
* \remark For a complete overview, take a look at \ref argument_parser
*/
template <seqan3::arithmetic option_value_t>
template <typename option_value_t>
//!\cond
requires std::is_arithmetic_v<option_value_t>
//!\endcond
class arithmetic_range_validator
{
public:
Expand All @@ -96,13 +99,13 @@ class arithmetic_range_validator

/*!\brief Tests whether every element in \p range lies inside [`min`, `max`].
* \tparam range_type The type of range to check; must model std::ranges::forward_range. The value type must model
* seqan3::arithmetic.
* std::is_arithmetic_v.
* \param range The input range to iterate over and check every element.
* \throws sharg::validation_error
*/
template <std::ranges::forward_range range_type>
//!\cond
requires seqan3::arithmetic<std::ranges::range_value_t<range_type>>
requires std::is_arithmetic_v<std::ranges::range_value_t<range_type>>
//!\endcond
void operator()(range_type const & range) const
{
Expand Down

1 comment on commit a3dedd1

@vercel
Copy link

@vercel vercel bot commented on a3dedd1 Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.