From 1fbf955272c93516ca9484831f5cfbc2afb0fbe3 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 001/121] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] From b1dc87da3c6949de1e07218ca3140df1e0147a7d Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 24 Apr 2006 08:02:07 +0000 Subject: [PATCH 002/121] Merge from trunk [SVN r33777] --- src/options_description.cpp | 13 ++++++------- test/options_description_test.cpp | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/options_description.cpp b/src/options_description.cpp index 6408502b39..7ce5aadc0f 100644 --- a/src/options_description.cpp +++ b/src/options_description.cpp @@ -390,13 +390,12 @@ namespace boost { namespace program_options { } } - string::const_iterator line_end; - - line_end = line_begin + line_length; - if (line_end > par_end) - { - line_end = par_end; - } + // Take care to never increment the iterator past + // the end, since MSVC 8.0 (brokenly), assumes that + // doing that, even if no access happens, is a bug. + unsigned remaining = distance(line_begin, par_end); + string::const_iterator line_end = line_begin + + ((remaining < line_length) ? remaining : line_length); // prevent chopped words // Is line_end between two non-space characters? diff --git a/test/options_description_test.cpp b/test/options_description_test.cpp index 60a4ebbc42..d5ec259020 100644 --- a/test/options_description_test.cpp +++ b/test/options_description_test.cpp @@ -15,6 +15,7 @@ using namespace boost; #include #include +#include using namespace std; void test_type() @@ -61,9 +62,25 @@ void test_approximation() // BOOST_CHECK(*(++a.begin()) == "foo"); } +void test_formatting() +{ + // Long option descriptions used to crash on MSVC-8.0. + options_description desc; + desc.add_options()( + "test", new untyped_value(), + "foo foo foo foo foo foo foo foo foo foo foo foo foo foo" + "foo foo foo foo foo foo foo foo foo foo foo foo foo foo" + "foo foo foo foo foo foo foo foo foo foo foo foo foo foo" + "foo foo foo foo foo foo foo foo foo foo foo foo foo foo"); + + stringstream ss; + ss << desc; +} + int test_main(int, char* []) { test_type(); test_approximation(); + test_formatting(); return 0; } From 252a3f9ebd8004b87565f680f34e5e2b9613761c Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 24 Apr 2006 08:29:05 +0000 Subject: [PATCH 003/121] Merge from trunk [SVN r33779] --- src/value_semantic.cpp | 7 +++++-- test/parsers_test.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index 9298536cc4..0cdf69957a 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -170,9 +170,12 @@ namespace boost { namespace program_options { { check_first_occurrence(v); string s(get_single_string(xs)); - if (*s.begin() == '\'' && *s.rbegin() == '\'' || - *s.begin() == '"' && *s.rbegin() == '"') + if (!s.empty() && ( + (*s.begin() == '\'' && *s.rbegin() == '\'' || + *s.begin() == '"' && *s.rbegin() == '"'))) + { v = any(s.substr(1, s.size()-2)); + } else v = any(s); } diff --git a/test/parsers_test.cpp b/test/parsers_test.cpp index 17aaf92b43..e292d7d330 100644 --- a/test/parsers_test.cpp +++ b/test/parsers_test.cpp @@ -133,6 +133,16 @@ void test_command_line() check_value(a4[0], "foo", "4"); check_value(a4[1], "bar", "11"); + // Check that we don't crash on empty values of type 'string' + char* cmdline4[] = {"", "--open", ""}; + options_description desc2; + desc2.add_options() + ("open", po::value()) + ; + variables_map vm; + po::store(po::parse_command_line(3, cmdline4, desc2), vm); + + } From ac9830625be04f75323f637777b61ef18178f17c Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 24 Apr 2006 08:52:43 +0000 Subject: [PATCH 004/121] Merge from trunk [SVN r33781] --- doc/tutorial.xml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/tutorial.xml b/doc/tutorial.xml index 3d3fb84e77..4a89eba204 100644 --- a/doc/tutorial.xml +++ b/doc/tutorial.xml @@ -96,7 +96,7 @@ Compression level was set to 10. An option value, surely, can have other types than int, and can have other interesting properties, which we'll discuss right now. The complete version of the code snipped below can be found in - "example/options_description.cpp". + example/options_description.cpp. Imagine we're writing a compiler. It should take the optimization level, a number of include paths, and a number of input files, and perform some @@ -115,21 +115,29 @@ desc.add_options() - The "--help" option should be familiar from the previous example. - It's a good idea to have this option in all cases. + The "help" option should be familiar from + the previous example. It's a good idea to have this option in all cases. + - The "optimization" option shows two new features. First, we specify + The "optimization" option shows two new features. First, we specify the address of the variable(&opt). After storing values, that variable will have the value of the option. Second, we specify a default value of 10, which will be used if no value is specified by the user. - The "include-path" option is an example of the only case where - the interface of the options_description class serves only one + The "include-path" option is an example of the + only case where the interface of the options_description + class serves only one source -- the command line. Users typically like to use short option names for common options, and the "include-path,I" name specifies that short option name is "I". So, both "--include-path" and "-I" can be used. + + Note also that the type of the "include-path" + option is std::vector. The library provides special + support for vectors -- it will be possible to specify the option several + times, and all specified values will be collected in one vector. + The "input-file" option specifies the list of files to process. That's okay for a start, but, of course, writing something like: @@ -337,7 +345,7 @@ Optimization level is 4 \ No newline at end of file +--> diff --git a/doc/howto.xml b/doc/howto.xml index 0841c9f1e2..0e3b6d655f 100644 --- a/doc/howto.xml +++ b/doc/howto.xml @@ -23,7 +23,7 @@ options groups/hidden options Non-conventional Syntax Sometimes, standard command line syntaxes are not enough. For - example, the gcc compiler has "-frtti" and -fno-rtti" options, and this + example, the gcc compiler has "-frtti" and "-fno-rtti" options, and this syntax is not directly supported. @@ -66,7 +66,7 @@ store(command_line_parser(ac, av).options(desc).extra_parser(reg_foo) response files - Some operating system have very low limits of the command line + Some operating systems have very low limits of the command line length. The common way to work around those limitations is using response files. A response file is just a configuration file which uses the same syntax as the command line. If @@ -304,7 +304,7 @@ void validate(boost::any& v, for the value, and in this case is either empty or contains an instance of the magic_number class. The second is the list of strings found in the next occurrence of the option. The remaining two parameters - are needed to workaround the lack of partial template specialization and + are needed to work around the lack of partial template specialization and partial function template ordering on some compilers. @@ -346,7 +346,7 @@ void validate(boost::any& v, some Unicode-aware options. They are different from ordinary options in that they accept wstring input, and process it using wide character streams. Creating an Unicode-aware option - is easy: just use the the wvalue function instead of the + is easy: just use the wvalue function instead of the regular value. @@ -379,7 +379,7 @@ locale::global(locale("")); implementation, though. The quick test involves three steps: - Go the the "test" directory and build the "test_convert" binary. + Go to the "test" directory and build the "test_convert" binary. Set some non-ascii locale in the environment. On Linux, one can diff --git a/doc/overview.xml b/doc/overview.xml index 52fe9b9865..677c7ae7d3 100644 --- a/doc/overview.xml +++ b/doc/overview.xml @@ -50,7 +50,7 @@ provides a class which stores all option values and that class can be freely passed around your program to modules which need access to the options. All the other components can be used only in the place where - the actual parsing is the done. However, it might also make sense for the + the actual parsing is done. However, it might also make sense for the individual program modules to describe their options and pass them to the main module, which will merge all options. Of course, this is only important when the number of options is large and declaring them in one @@ -208,7 +208,7 @@ desc.add_options() The description string has one or more paragraphs, separated by the newline character ('\n'). When an option is output, the library will compute the indentation for options's description. Each of the - paragraph is output as a separate line with that intentation. If + paragraph is output as a separate line with that indentation. If a paragraph does not fit on one line it is spanned over multiple lines (which will have the same indentation). @@ -538,7 +538,7 @@ desc.add_options() The environment variables can be parsed with the - &parse_environment; function. The function have several overloaded + &parse_environment; function. The function has several overloaded versions. The first parameter is always an &options_description; instance, and the second specifies what variables must be processed, and what option names must correspond to it. To describe the second @@ -546,13 +546,13 @@ desc.add_options() variables. If you have an option that should be specified via environment - variable, you need make up the variable's name. To avoid name clashes, + variable, you need to make up the variable's name. To avoid name clashes, we suggest that you use a sufficiently unique prefix for environment variables. Also, while option names are most likely in lower case, environment variables conventionally use upper case. So, for an option name proxy the environment variable might be called BOOST_PROXY. During parsing, we need to perform reverse - conversion of the names. This is accomplished by passing the choosen + conversion of the names. This is accomplished by passing the chosen prefix as the second parameter of the &parse_environment; function. Say, if you pass BOOST_ as the prefix, and there are two variables, CVSROOT and BOOST_PROXY, the @@ -588,7 +588,7 @@ desc.add_options() representations that are available in C++ literals are not supported by lexical_cast, and thus will not work with program_options. - Booleans a special in that there are multiple ways to come at them. + Booleans are special in that there are multiple ways to come at them. Similar to another value type, it can be specified as ("my-option", value<bool>()), and then set as: @@ -648,7 +648,7 @@ example --other-switch &parse_command_line; - parses command line (simpified interface) + parses command line (simplified interface) diff --git a/doc/program_options.xml b/doc/program_options.xml index cd879f7d65..c9455683be 100644 --- a/doc/program_options.xml +++ b/doc/program_options.xml @@ -70,7 +70,7 @@ - Now let's see some examples of the library usage in the . diff --git a/include/boost/program_options/cmdline.hpp b/include/boost/program_options/cmdline.hpp index 8705e60f21..8b57819d85 100644 --- a/include/boost/program_options/cmdline.hpp +++ b/include/boost/program_options/cmdline.hpp @@ -9,7 +9,7 @@ namespace boost { namespace program_options { namespace command_line_style { /** Various possible styles of options. - There are "long" options, which start with "--" and "short", + There are "long" options, which start with "--", and "short", which start with either "-" or "/". Both kinds can be allowed or disallowed, see allow_long and allow_short. The allowed character for short options is also configurable. @@ -51,7 +51,7 @@ namespace boost { namespace program_options { namespace command_line_style { /** Allow to merge several short options together, so that "-s -k" become "-sk". All of the options but last should accept no parameter. For example, if - "-s" accept a parameter, then "k" will be taken as + "-s" accepts a parameter, then "k" will be taken as parameter, not another short option. Dos-style short options cannot be sticky. */ diff --git a/include/boost/program_options/eof_iterator.hpp b/include/boost/program_options/eof_iterator.hpp index 5e53df5b81..c95d27f6b6 100644 --- a/include/boost/program_options/eof_iterator.hpp +++ b/include/boost/program_options/eof_iterator.hpp @@ -11,12 +11,12 @@ namespace boost { /** The 'eof_iterator' class is useful for constructing forward iterators - in cases where iterator extract data from some source and it's easy + in cases where the iterator extracts data from some source and it's easy to detect 'eof' \-- i.e. the situation where there's no data. One apparent example is reading lines from a file. Implementing such iterators using 'iterator_facade' directly would - require to create class with three core operation, a couple of + require to create class with three core operations, a couple of constructors. When using 'eof_iterator', the derived class should define only one method to get new value, plus a couple of constructors. diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 56674bf245..5b4d1d3d59 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -51,7 +51,7 @@ namespace boost { namespace program_options { {} }; - /** Class thrown when there are programming error related to style */ + /** Class thrown when there are programming errors related to style */ class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE invalid_command_line_style : public error { public: invalid_command_line_style(const std::string& msg) @@ -83,7 +83,7 @@ namespace boost { namespace program_options { * Options are displayed in "canonical" form * This is the most unambiguous form of the * *parsed* option name and would correspond to - * option_description::format_name() + * option_description::format_name(), * i.e. what is shown by print_usage() * * The "canonical" form depends on whether the option is @@ -243,7 +243,7 @@ namespace boost { namespace program_options { * It makes no sense to have an option name, when we can't match an option to the * parameter * - * Having this a part of the error_with_option_name hierachy makes error handling + * Having this as part of the error_with_option_name hierarchy makes error handling * a lot easier, even if the name indicates some sort of conceptual dissonance! * * */ @@ -275,7 +275,7 @@ namespace boost { namespace program_options { - /** Class thrown when there's ambiguity amoung several possible options. */ + /** Class thrown when there's ambiguity among several possible options. */ class BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_VISIBLE ambiguous_option : public error_with_no_option_name { public: ambiguous_option(const std::vector& xalternatives) diff --git a/include/boost/program_options/options_description.hpp b/include/boost/program_options/options_description.hpp index 90d913d3e3..da2c4bbfe3 100644 --- a/include/boost/program_options/options_description.hpp +++ b/include/boost/program_options/options_description.hpp @@ -105,7 +105,7 @@ namespace program_options { /** Returns the canonical name for the option description to enable the user to - recognised a matching option. + recognise a matching option. 1) For short options ('-', '/'), returns the short name prefixed. 2) For long options ('--' / '-') returns the first long name prefixed 3) All other cases, returns the first long name (if present) or the short diff --git a/include/boost/program_options/parsers.hpp b/include/boost/program_options/parsers.hpp index 230af29e3d..c86b537469 100644 --- a/include/boost/program_options/parsers.hpp +++ b/include/boost/program_options/parsers.hpp @@ -150,7 +150,7 @@ namespace boost { namespace program_options { instance of basic_option will be added to result, with 'unrecognized' field set to 'true'. It's possible to collect all unrecognized options with the 'collect_unrecognized' - funciton. + function. */ basic_command_line_parser& allow_unregistered(); @@ -214,7 +214,7 @@ namespace boost { namespace program_options { /** Collects the original tokens for all named options with 'unregistered' flag set. If 'mode' is 'include_positional' also collects all positional options. - Returns the vector of origianl tokens for all collected + Returns the vector of original tokens for all collected options. */ template @@ -254,8 +254,8 @@ namespace boost { namespace program_options { /** Splits a given string to a collection of single strings which can be passed to command_line_parser. The second parameter is - used to specify a collection of possible seperator chars used - for splitting. The seperator is defaulted to space " ". + used to specify a collection of possible separator chars used + for splitting. The separator is defaulted to space " ". Splitting is done in a unix style way, with respect to quotes '"' and escape characters '\' */ diff --git a/include/boost/program_options/positional_options.hpp b/include/boost/program_options/positional_options.hpp index ac2a3122d5..c19c9250ea 100644 --- a/include/boost/program_options/positional_options.hpp +++ b/include/boost/program_options/positional_options.hpp @@ -37,7 +37,7 @@ namespace boost { namespace program_options { public: positional_options_description(); - /** Species that up to 'max_count' next positional options + /** Specifies that up to 'max_count' next positional options should be given the 'name'. The value of '-1' means 'unlimited'. No calls to 'add' can be made after call with 'max_value' equal to '-1'. diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index ac9dbc663b..82657499bd 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -51,7 +51,7 @@ namespace boost { namespace program_options { /** Parses a group of tokens that specify a value of option. Stores the result in 'value_store', using whatever representation - is desired. May be be called several times if value of the same + is desired. May be called several times if value of the same option is specified more than once. */ virtual void parse(boost::any& value_store, @@ -71,7 +71,7 @@ namespace boost { namespace program_options { virtual ~value_semantic() {} }; - /** Helper class which perform necessary character conversions in the + /** Helper class which performs necessary character conversions in the 'parse' method and forwards the data further. */ template @@ -140,7 +140,7 @@ namespace boost { namespace program_options { bool is_required() const { return false; } /** If 'value_store' is already initialized, or new_tokens - has more than one elements, throws. Otherwise, assigns + has more than one element, throws. Otherwise, assigns the first string from 'new_tokens' to 'value_store', without any modifications. */ @@ -157,7 +157,7 @@ namespace boost { namespace program_options { }; #ifndef BOOST_NO_RTTI - /** Base class for all option that have a fixed type, and are + /** Base class for all options that have a fixed type, and are willing to announce this type to the outside world. Any 'value_semantics' for which you want to find out the type can be dynamic_cast-ed to typed_value_base. If conversion @@ -218,7 +218,7 @@ namespace boost { namespace program_options { /** Specifies an implicit value, which will be used if the option is given, but without an adjacent value. - Using this implies that an explicit value is optional, + Using this implies that an explicit value is optional. */ typed_value* implicit_value(const T &v) { @@ -228,7 +228,7 @@ namespace boost { namespace program_options { return this; } - /** Specifies the name used to to the value in help message. */ + /** Specifies the name used for the value in the help message. */ typed_value* value_name(const std::string& name) { m_value_name = name; @@ -278,7 +278,7 @@ namespace boost { namespace program_options { } /** Specifies that no tokens may be provided as the value of - this option, which means that only presense of the option + this option, which means that only presence of the option is significant. For such option to be useful, either the 'validate' function should be specialized, or the 'implicit_value' method should be also used. In most diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index 362dedf283..a21adabcab 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -62,7 +62,7 @@ namespace boost { namespace program_options { : v(xv), m_defaulted(xdefaulted) {} - /** If stored value if of type T, returns that value. Otherwise, + /** If stored value is of type T, returns that value. Otherwise, throws boost::bad_any_cast exception. */ template const T& as() const { @@ -138,7 +138,7 @@ namespace boost { namespace program_options { const abstract_variables_map* m_next; }; - /** Concrete variables map which store variables in real map. + /** Concrete variables map which stores variables in real map. This class is derived from std::map, so you can use all map operators to examine its content. From 5fd247085c435468529a1a554257eb5b60032fd6 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Fri, 12 Sep 2025 11:21:44 -0400 Subject: [PATCH 116/121] Add override on overriden functions for c++11 (#145) Signed-off-by: Ben Magistro --- include/boost/program_options/errors.hpp | 8 ++-- .../boost/program_options/value_semantic.hpp | 38 +++++++++---------- .../boost/program_options/variables_map.hpp | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/include/boost/program_options/errors.hpp b/include/boost/program_options/errors.hpp index 5b4d1d3d59..953db13667 100644 --- a/include/boost/program_options/errors.hpp +++ b/include/boost/program_options/errors.hpp @@ -183,7 +183,7 @@ namespace boost { namespace program_options { /** Creates the error_message on the fly * Currently a thin wrapper for substitute_placeholders() */ - virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW; + virtual const char* what() const BOOST_NOEXCEPT_OR_NOTHROW override; protected: /** Used to hold the error text returned by what() */ @@ -256,7 +256,7 @@ namespace boost { namespace program_options { } /** Does NOT set option name, because no option name makes sense */ - virtual void set_option_name(const std::string&) {} + virtual void set_option_name(const std::string&) override {} BOOST_DEFAULTED_FUNCTION(~error_with_no_option_name() BOOST_NOEXCEPT_OR_NOTHROW, {}) }; @@ -289,7 +289,7 @@ namespace boost { namespace program_options { protected: /** Makes all substitutions using the template */ - virtual void substitute_placeholders(const std::string& error_template) const; + virtual void substitute_placeholders(const std::string& error_template) const override; private: // TODO: copy ctor might throw std::vector m_alternatives; @@ -343,7 +343,7 @@ namespace boost { namespace program_options { BOOST_DEFAULTED_FUNCTION(~invalid_config_file_syntax() BOOST_NOEXCEPT_OR_NOTHROW, {}) /** Convenience functions for backwards compatibility */ - virtual std::string tokens() const {return m_substitutions.find("invalid_line")->second; } + virtual std::string tokens() const override {return m_substitutions.find("invalid_line")->second; } }; diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index 82657499bd..717f2cd99a 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -92,7 +92,7 @@ namespace boost { namespace program_options { private: // base overrides void parse(boost::any& value_store, const std::vector& new_tokens, - bool utf8) const; + bool utf8) const override; protected: // interface for derived classes. virtual void xparse(boost::any& value_store, const std::vector& new_tokens) @@ -112,7 +112,7 @@ namespace boost { namespace program_options { private: // base overrides void parse(boost::any& value_store, const std::vector& new_tokens, - bool utf8) const; + bool utf8) const override; protected: // interface for derived classes. #if !defined(BOOST_NO_STD_WSTRING) virtual void xparse(boost::any& value_store, @@ -130,14 +130,14 @@ namespace boost { namespace program_options { : m_zero_tokens(zero_tokens) {} - std::string name() const; + std::string name() const override; - unsigned min_tokens() const; - unsigned max_tokens() const; + unsigned min_tokens() const override; + unsigned max_tokens() const override; - bool is_composing() const { return false; } + bool is_composing() const override { return false; } - bool is_required() const { return false; } + bool is_required() const override { return false; } /** If 'value_store' is already initialized, or new_tokens has more than one element, throws. Otherwise, assigns @@ -145,13 +145,13 @@ namespace boost { namespace program_options { any modifications. */ void xparse(boost::any& value_store, - const std::vector& new_tokens) const; + const std::vector& new_tokens) const override; /** Does nothing. */ - bool apply_default(boost::any&) const { return false; } + bool apply_default(boost::any&) const override { return false; } /** Does nothing. */ - void notify(const boost::any&) const {} + void notify(const boost::any&) const override {} private: bool m_zero_tokens; }; @@ -299,11 +299,11 @@ namespace boost { namespace program_options { public: // value semantic overrides - std::string name() const; + std::string name() const override; - bool is_composing() const { return m_composing; } + bool is_composing() const override { return m_composing; } - unsigned min_tokens() const + unsigned min_tokens() const override { if (m_zero_tokens || !m_implicit_value.empty()) { return 0; @@ -312,7 +312,7 @@ namespace boost { namespace program_options { } } - unsigned max_tokens() const { + unsigned max_tokens() const override { if (m_multitoken) { return std::numeric_limits::max BOOST_PREVENT_MACRO_SUBSTITUTION(); } else if (m_zero_tokens) { @@ -322,19 +322,19 @@ namespace boost { namespace program_options { } } - bool is_required() const { return m_required; } + bool is_required() const override { return m_required; } /** Creates an instance of the 'validator' class and calls its operator() to perform the actual conversion. */ void xparse(boost::any& value_store, const std::vector< std::basic_string >& new_tokens) - const; + const override; /** If default value was specified via previous call to 'default_value', stores that value into 'value_store'. Returns true if default value was stored. */ - virtual bool apply_default(boost::any& value_store) const + virtual bool apply_default(boost::any& value_store) const override { if (m_default_value.empty()) { return false; @@ -347,12 +347,12 @@ namespace boost { namespace program_options { /** If an address of variable to store value was specified when creating *this, stores the value there. Otherwise, does nothing. */ - void notify(const boost::any& value_store) const; + void notify(const boost::any& value_store) const override; public: // typed_value_base overrides #ifndef BOOST_NO_RTTI - const std::type_info& value_type() const + const std::type_info& value_type() const override { return typeid(T); } diff --git a/include/boost/program_options/variables_map.hpp b/include/boost/program_options/variables_map.hpp index a21adabcab..3d76629311 100644 --- a/include/boost/program_options/variables_map.hpp +++ b/include/boost/program_options/variables_map.hpp @@ -162,7 +162,7 @@ namespace boost { namespace program_options { private: /** Implementation of abstract_variables_map::get which does 'find' in *this. */ - const variable_value& get(const std::string& name) const; + const variable_value& get(const std::string& name) const override; /** Names of option with 'final' values \-- which should not be changed by subsequence assignments. */ From 6b2bc88964f9b32c64dae8584a04ff680d7d0eac Mon Sep 17 00:00:00 2001 From: Marcos Simental Date: Sat, 13 Sep 2025 03:36:14 -0600 Subject: [PATCH 117/121] Fix listing typo (#130) The paragraph lists a couple of options and expands information on each element. However, the following explanation lists the first element, the first, the third, and the last, whereas the logic of the discussion aims to explain the listing as first, second, third, and last elements. --- doc/overview.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/overview.xml b/doc/overview.xml index 677c7ae7d3..2b554aec3e 100644 --- a/doc/overview.xml +++ b/doc/overview.xml @@ -187,7 +187,7 @@ desc.add_options() For the first parameter, we specify only the name and the description. No value can be specified in the parsed source. - For the first option, the user must specify a value, using a single + For the second option, the user must specify a value, using a single token. For the third option, the user may either provide a single token for the value, or no token at all. For the last option, the value can span several tokens. For example, the following command line is OK: From 902aaedaaa157a92e649c3b1324c92f5a264a805 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 13 Sep 2025 10:38:35 +0100 Subject: [PATCH 118/121] overview.xml: clarify wording --- doc/overview.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/overview.xml b/doc/overview.xml index 2b554aec3e..ab1b733b70 100644 --- a/doc/overview.xml +++ b/doc/overview.xml @@ -185,7 +185,7 @@ desc.add_options() ("email", value<string>()->multitoken(), "email to send to") ; - For the first parameter, we specify only the name and the + For the first option, we specify only the name and the description. No value can be specified in the parsed source. For the second option, the user must specify a value, using a single token. For the third option, the user may either provide a single token From ec6794632fd7e6050a69480ea3e5b2a5d5b3c08d Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Dec 2025 11:07:35 +0000 Subject: [PATCH 119/121] Move 'arg' variable to detail namespace (#151) Closes #150. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Vladimir Prus --- include/boost/program_options/detail/value_semantic.hpp | 6 ++++-- src/value_semantic.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/boost/program_options/detail/value_semantic.hpp b/include/boost/program_options/detail/value_semantic.hpp index 80e292510e..27b7c241b5 100644 --- a/include/boost/program_options/detail/value_semantic.hpp +++ b/include/boost/program_options/detail/value_semantic.hpp @@ -17,13 +17,15 @@ namespace boost { template class optional; } namespace boost { namespace program_options { - extern BOOST_PROGRAM_OPTIONS_DECL std::string arg; + namespace detail { + extern BOOST_PROGRAM_OPTIONS_DECL std::string arg; + } template std::string typed_value::name() const { - std::string const& var = (m_value_name.empty() ? arg : m_value_name); + std::string const& var = (m_value_name.empty() ? detail::arg : m_value_name); if (!m_implicit_value.empty() && !m_implicit_value_as_text.empty()) { std::string msg = "[=" + var + "(=" + m_implicit_value_as_text + ")]"; if (!m_default_value.empty() && !m_default_value_as_text.empty()) diff --git a/src/value_semantic.cpp b/src/value_semantic.cpp index de7b2ace84..c4feb688e3 100644 --- a/src/value_semantic.cpp +++ b/src/value_semantic.cpp @@ -84,12 +84,14 @@ namespace boost { namespace program_options { } #endif - BOOST_PROGRAM_OPTIONS_DECL std::string arg("arg"); + namespace detail { + BOOST_PROGRAM_OPTIONS_DECL std::string arg("arg"); + } std::string untyped_value::name() const { - return arg; + return detail::arg; } unsigned From 486e3418ff92f49522e813e48b18d73e85290f45 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 22 Jan 2026 21:14:06 +0300 Subject: [PATCH 120/121] Remove dependencies on Boost.StaticAssert. (#155) Boost.StaticAssert has been merged into Boost.Config, so remove the dependency. --- CMakeLists.txt | 1 - build.jam | 1 - 2 files changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb9ba621df..024966ee2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ target_link_libraries(boost_program_options Boost::iterator Boost::lexical_cast Boost::smart_ptr - Boost::static_assert Boost::throw_exception Boost::type_traits PRIVATE diff --git a/build.jam b/build.jam index 15f41a3307..566b2573ef 100644 --- a/build.jam +++ b/build.jam @@ -14,7 +14,6 @@ constant boost_dependencies : /boost/iterator//boost_iterator /boost/lexical_cast//boost_lexical_cast /boost/smart_ptr//boost_smart_ptr - /boost/static_assert//boost_static_assert /boost/throw_exception//boost_throw_exception /boost/type_traits//boost_type_traits ; From acdf8eefe8266c3c3f511424cad1701595561970 Mon Sep 17 00:00:00 2001 From: Ahmed Abou Aliaa Date: Thu, 19 Feb 2026 21:12:50 +0100 Subject: [PATCH 121/121] fixes #88: macros with no BOOST_ prefix (#89) --- include/boost/program_options.hpp | 6 +++--- include/boost/program_options/config.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/program_options.hpp b/include/boost/program_options.hpp index dc35011957..46e1b7d3a5 100644 --- a/include/boost/program_options.hpp +++ b/include/boost/program_options.hpp @@ -5,8 +5,8 @@ // See www.boost.org/libs/program_options for documentation. -#ifndef PROGRAM_OPTIONS_VP_2003_05_19 -#define PROGRAM_OPTIONS_VP_2003_05_19 +#ifndef BOOST_PROGRAM_OPTIONS_VP_2003_05_19 +#define BOOST_PROGRAM_OPTIONS_VP_2003_05_19 #if defined(_MSC_VER) #pragma once @@ -22,4 +22,4 @@ #include #include -#endif +#endif // BOOST_PROGRAM_OPTIONS_VP_2003_05_19 diff --git a/include/boost/program_options/config.hpp b/include/boost/program_options/config.hpp index 8b70521741..69141726b9 100644 --- a/include/boost/program_options/config.hpp +++ b/include/boost/program_options/config.hpp @@ -48,5 +48,5 @@ #endif -#endif // PROGRAM_OPTIONS_CONFIG_HK_2004_01_11 +#endif // BOOST_PROGRAM_OPTIONS_CONFIG_HK_2004_01_11