Skip to content

Commit 2b8bac6

Browse files
authored
Allow argc to be zero
1 parent 3aae04b commit 2b8bac6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/boost/program_options/detail/parsers.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace boost { namespace program_options {
2424
basic_command_line_parser<charT>::
2525
basic_command_line_parser(int argc, const charT* const argv[])
2626
: detail::cmdline(
27-
to_internal(std::vector<std::basic_string<charT> >(argv+1, argv+argc))),
27+
to_internal(std::vector<std::basic_string<charT> >(argc ? argv+1 : argv, argv+argc))),
2828
m_desc()
2929
{}
3030

include/boost/program_options/parsers.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,11 @@ namespace boost { namespace program_options {
120120
basic_command_line_parser(const std::vector<
121121
std::basic_string<charT> >& args);
122122
/** Creates a command line parser for the specified arguments
123-
list. The parameters should be the same as passed to 'main'.
123+
list. The parameters should be the same as passed to 'main', meaning:
124+
@param argc Must be non-negative i.e. >= 0
125+
@param argv Argv[argc] must be 0 e.g. nullptr and
126+
if argc is >0 argv[0] up to argv[argc-1] must point to
127+
null terminated strings
124128
*/
125129
basic_command_line_parser(int argc, const charT* const argv[]);
126130

0 commit comments

Comments
 (0)