Skip to content

Commit

Permalink
Allow argc to be zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Superlokkus authored Dec 16, 2023
1 parent 3aae04b commit 2b8bac6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/boost/program_options/detail/parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace boost { namespace program_options {
basic_command_line_parser<charT>::
basic_command_line_parser(int argc, const charT* const argv[])
: detail::cmdline(
to_internal(std::vector<std::basic_string<charT> >(argv+1, argv+argc))),
to_internal(std::vector<std::basic_string<charT> >(argc ? argv+1 : argv, argv+argc))),
m_desc()
{}

Expand Down
6 changes: 5 additions & 1 deletion include/boost/program_options/parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ namespace boost { namespace program_options {
basic_command_line_parser(const std::vector<
std::basic_string<charT> >& args);
/** Creates a command line parser for the specified arguments
list. The parameters should be the same as passed to 'main'.
list. The parameters should be the same as passed to 'main', meaning:
@param argc Must be non-negative i.e. >= 0
@param argv Argv[argc] must be 0 e.g. nullptr and
if argc is >0 argv[0] up to argv[argc-1] must point to
null terminated strings
*/
basic_command_line_parser(int argc, const charT* const argv[]);

Expand Down

0 comments on commit 2b8bac6

Please sign in to comment.