From 2b8bac66a9911fe537a7e04e25642f44a6aaf5ca Mon Sep 17 00:00:00 2001 From: Markus Klemm Date: Sat, 16 Dec 2023 19:35:09 +0100 Subject: [PATCH] Allow argc to be zero --- include/boost/program_options/detail/parsers.hpp | 2 +- include/boost/program_options/parsers.hpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/boost/program_options/detail/parsers.hpp b/include/boost/program_options/detail/parsers.hpp index b644aaa176..cdda539cae 100644 --- a/include/boost/program_options/detail/parsers.hpp +++ b/include/boost/program_options/detail/parsers.hpp @@ -24,7 +24,7 @@ namespace boost { namespace program_options { basic_command_line_parser:: basic_command_line_parser(int argc, const charT* const argv[]) : detail::cmdline( - to_internal(std::vector >(argv+1, argv+argc))), + to_internal(std::vector >(argc ? argv+1 : argv, argv+argc))), m_desc() {} diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index 0576469278..7d902690a8 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -120,7 +120,11 @@ namespace boost { namespace program_options { basic_command_line_parser(const std::vector< std::basic_string >& 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[]);