
What am I doing wrong? I get error 'boost::program_options::typed_value<T> *boost::program_options::value(T *)' : expects 1 arguments - 0 provided class options { public: unsigned int _option1; int _option2; void parse_options() { boost::program_options::options_description config; config.add_options() ("set1", boost::program_options::value<&_option1>()->default_value(200), "seting 1") ("set2", boost::program_options::value<&_option2>()->default_value(300), "seting 2"); } }; Thanks for help

Hi there, change the template parameter to the real type.
program_options::value<&_option1>() ----->>>
program_options::value<unsigned int>()
That's it,
Christian
On 3/7/07, Aljaz
What am I doing wrong? I get error 'boost::program_options::typed_value<T> *boost::program_options::value(T *)' : expects 1 arguments - 0 provided
class options { public: unsigned int _option1; int _option2;
void parse_options() { boost::program_options::options_description config; config.add_options() ("set1", boost::program_options::value<&_option1>()->default_value(200), "seting 1") ("set2", boost::program_options::value<&_option2>()->default_value(300), "seting 2"); } };
Thanks for help
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Aljaz wrote:
What am I doing wrong? I get error 'boost::program_options::typed_value<T> *boost::program_options::value(T *)' : expects 1 arguments - 0 provided
class options { public: unsigned int _option1; int _option2;
void parse_options() { boost::program_options::options_description config; config.add_options() ("set1", boost::program_options::value<&_option1>()->default_value(200), "seting 1") ("set2", boost::program_options::value<&_option2>()->default_value(300), "seting 2"); } };
Thanks for help
Hi, it should be: boost::program_options::value<unsigned int>(&_option1)->default_value(200), "seting 1") -- Regards, dave

If I do: config.add_options() ("set1,s", boost::program_options::value<unsigned int>(&_option1)->default_value(20), "seting 1"); it will compile.. But when I run it I get assertion: Assertion failed: n == name.size()-2, file C:\...\boost\boost_1_33_1\libs\program_options\build\../src/options_description.cpp, line 118 If I remove ',s' from the function names, it seems to work ok.. It this a bug? Or am I missing something? Thanks for help again Best regards

Aljaz wrote:
If I do: config.add_options() ("set1,s", boost::program_options::value<unsigned int>(&_option1)->default_value(20), "seting 1");
it will compile.. But when I run it I get assertion:
Assertion failed: n == name.size()-2, file C:\...\boost\boost_1_33_1\libs\program_options\build\../src/options_description.cpp, line 118
If I remove ',s' from the function names, it seems to work ok..
It this a bug? Or am I missing something?
Would you mind posting a complete program that exposes this behaviour? Generally, a complete program is preferred for all bug reports against program_options, and I believe authors of other libraries prefer that too, as code snippets are neither compilable nor debuggable. - Volodya

Hey Vladimir I attached the whole code that does a crash.. Please take a look and let me know Aljaz
Would you mind posting a complete program that exposes this behaviour? Generally, a complete program is preferred for all bug reports against program_options, and I believe authors of other libraries prefer that too, as code snippets are neither compilable nor debuggable.
- Volodya
begin 666 program options.cpp
M(VEN8VQU9&4@/&)O;W-T+W!R;V=R86U?;W!T:6]N

Aljaz wrote:
Hey Vladimir
I attached the whole code that does a crash.. Please take a look and let me know
("timeout,to", boost::program_options::value(&_timeout)->default_value(3), "desc 2"); Here, "to" is invalid. The part after "," is supposed to be short option name, which is supposed to be a single letter. It is presently not supported to have several long option spellings. - Volodya
participants (4)
-
Aljaz
-
Christian Henning
-
David Klein
-
Vladimir Prus