
How would I specify an empty vector of strings as the default value for this option?
po::value< vector<string> >()->default_value(??)
Use vector<string>() as the default value.
Hi,
I have the same problem. But when I'm using :
configuration.add_options() ("DEFAULT.bytecompile",program_options::value< vector<string>
()->default_value(vector<string>())) ;
G++ won't compile.
Here is the complete source code :
#include <vector> #include
int main(int argc, char** argv) { using namespace std; using namespace boost;
program_options::options_description configuration; boost::program_options::variables_map vm; vector<string> empty_vector;
// Set options and default values configuration.add_options() ("DEFAULT.bytecompile",program_options::value< vector<string>
()->default_value(vector<string>())) ;
program_options::store ( program_options::parse_command_line(argc, argv, configuration) , vm );
program_options::notify( vm );
return 0; }
Ok. The solution is to specify a "textual" parameter : ("DEFAULT.bytecompile",program_options::value< vector<string>
()->default_value(vector<string>(),"")
/** Specifies default value, which will be used if none is explicitly specified. Unlike the above overload, the type 'T' need not provide operator<< for ostream, but textual representation of default value must be provided by the user. */ typed_value* default_value(const T& v, const std::string& textual);