template<typename option_value_t>
requires
std::is_arithmetic_v<option_value_t>
class sharg::arithmetic_range_validator< option_value_t >
A validator that checks whether a number is inside a given range.
- Template Parameters
-
On construction, the validator must receive a maximum and a minimum number. The class than acts as a functor, that throws a sharg::validation_error exception whenever a given value does not lie inside the given min/max range.
int main(int argc, char const ** argv)
{
int myint;
myparser.add_option(myint,
.long_id = "integer",
.description = "Give me a number.",
.validator = my_validator});
try
{
myparser.parse();
}
{
return -1;
}
std::cerr <<
"integer given by user passed validation: " << myint <<
"\n";
return 0;
}
Meta-header for the Parser module .
A validator that checks whether a number is inside a given range.
Definition validators.hpp:79
Parser exception that is thrown whenever there is an error while parsing the command line arguments.
Definition exceptions.hpp:40
The Sharg command line parser.
Definition parser.hpp:154
Option struct that is passed to the sharg::parser::add_option() function.
Definition config.hpp:43
char short_id
The short identifier for the option (e.g. 'a', making the option callable via -a).
Definition config.hpp:53
This entity is stable. Since version 1.0.