Skip to content

Commit

Permalink
Assert that args is not an unknown negative value.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzlaine committed Sep 13, 2020
1 parent c060329 commit 4c6fbcf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/boost/program_options_2/parse_command_line.hpp
Expand Up @@ -742,6 +742,9 @@ namespace boost { namespace program_options_2 {
// An argument with args=0 and no default is a flag. Use flag()
// instead.
BOOST_ASSERT(args != 0);
// args must be one of the named values, like zero_or_one, or must be
// non-negative.
BOOST_ASSERT(remainder <= args);
// If you specify more than one argument with args, T must be a type
// that can be inserted into.
BOOST_ASSERT(args == 1 || args == zero_or_one || detail::insertable<T>);
Expand Down Expand Up @@ -789,6 +792,9 @@ namespace boost { namespace program_options_2 {
BOOST_ASSERT(detail::positional(name));
// A value of 0 for args makes no sense for a positional argument.
BOOST_ASSERT(args != 0);
// args must be one of the named values, like zero_or_one, or must be
// non-negative.
BOOST_ASSERT(remainder <= args);
// If you specify more than one argument with args, T must be a type
// that can be inserted into.
BOOST_ASSERT(args == 1 || args == zero_or_one || detail::insertable<T>);
Expand All @@ -812,6 +818,9 @@ namespace boost { namespace program_options_2 {
{
// A value of 0 for args makes no sense for a positional argument.
BOOST_ASSERT(args != 0);
// args must be one of the named values, like zero_or_one, or must be
// non-negative.
BOOST_ASSERT(remainder <= args);
// If you specify more than one argument with args, T must be a type
// that can be inserted into.
BOOST_ASSERT(args == 1 || args == zero_or_one || detail::insertable<T>);
Expand Down Expand Up @@ -844,6 +853,9 @@ namespace boost { namespace program_options_2 {
#endif
// A value of 0 for args makes no sense for a positional argument.
BOOST_ASSERT(args != 0);
// args must be one of the named values, like zero_or_one, or must be
// non-negative.
BOOST_ASSERT(remainder <= args);
// If you specify more than one argument with args, T must be a type
// that can be inserted into.
BOOST_ASSERT(args == 1 || args == zero_or_one || detail::insertable<T>);
Expand Down

0 comments on commit 4c6fbcf

Please sign in to comment.