Allows users to opt-out of std::exit call in default arguments without
needing to replace with new --help and --version arguments.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This attempts to fix Issue #225-1 by reverting the change that turned a
std::bad_any_cast exception into a nullptr.
Reverts commit 357068156e.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
The intent of ": 1" is to use individual bits to store the bool state of
these class values. Because true != 0, this worked. But it was likely to
bite someone sometime. (My bad: 0fe17e22f6.)
This commit also adds m_accepts_optional_like_value to the bit field and
sets the default false value in the constructor.
Because we cannot set a default value during declaration (until C++20).
make sure future coders know to set the preferred default in the
constructor.
Closes#213
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This allows updating attached object properties without holding external
references to the various Argument and ArgumentParser objects.
Closes#227
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This allows checking whether user input was processed into the parser
or any attached subparsers.
Closes#212
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
std::less<Key> is the standard's default comparison function, we do not
need to re-declare the same function.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
clang-ci >= 13.0 is failing to compile a constexpr function pointer
assignment. This is possibly due to strtof (and family) not being
implemented as constexpr in the relevant libc++.
Closes#136Closes#156
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
Clears warnings for the following checks in clang-tidy:
readability-braces-around-statements
readability-else-after-return checks
Also adds hints about code style to CONTRIBUTING document.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
After upgrading g++ package to 12.1.0 on archlinux I see the following
compilation error:
/usr/include/argparse/argparse.hpp: In member function ‘void argparse::ArgumentParser::index_argument(list_iterator)’:
/usr/include/argparse/argparse.hpp:1167:34: error: ‘as_const’ is not a member of ‘std’; did you mean ‘is_const’?
1167 | for (const auto &name : std::as_const(it->m_names)) {
| ^~~~~~~~
| is_const
It turns out that std::as_const comes from <utility> header [1] which
was not explicitly included.
[1] https://en.cppreference.com/w/cpp/utility/as_const
As far as I can tell, this statement is never true.
When m_values.size() < *expected, ::consume has already thrown "Too few
arguments..." before ::validate is called.
When m_values.size() > *expected, ArgumentParser::parse_args_internal
has already thrown "Maximum number of positional arguments exceeded"
before ::validate is called.
If ::remaining is used to avoid the last exception, this Argument will
always consume the expected number of values, hence this expression is
again false.
Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>