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 <aljaz.fajmut@siol.net> 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
_______________________________________________ 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<RYH<' ^#0HC:6YC;'5D M92 \8F]O<W0O;F]N8V]P>6%B;&4N:'!P/@T*#0HC:6YC;'5D92 \:6]S=')E M86T^#0HC:6YC;'5D92 \9G-T<F5A;3X-"B-I;F-L=61E(#QI=&5R871O<CX- M"B-I;F-L=61E(#QS=')I;F<^#0HC:6YC;'5D92 \<W1D97AC97!T/@T*#0IC M;&%S<R!O<'1I;VYS(#H@<')I=F%T92!B;V]S=#HZ;F]N8V]P>6%B;&4@>PT* M<'5B;&EC.@T*"6]P=&EO;G,H*2 Z(%]C;VUM86YD*")C;VUM86YD(&QI;F4B M*2P@7V-O;F9I9R@B8V]N9FEG=7)A=&EO;B(I('L-"@D)8F]O<W0Z.G!R;V=R M86U?;W!T:6]N<SHZ;W!T:6]N<U]D97-C<FEP=&EO;B!C;VUM86YD.PT*"0EC M;VUM86YD+F%D9%]O<'1I;VYS*"D-"@D)"2@B:&5L<"QH(BP)"2)P<F]D=6-E M(&AE;' @;65S<V%G92(I.PT*#0H)"6)O;W-T.CIP<F]G<F%M7V]P=&EO;G,Z M.F]P=&EO;G-?9&5S8W)I<'1I;VX@8V]N9FEG.PT*"0EC;VYF:6<N861D7V]P M=&EO;G,H*0T*"0D)*")P;W)T+&QP(BP)"6)O;W-T.CIP<F]G<F%M7V]P=&EO M;G,Z.G9A;'5E*"9?<&]R="DM/F1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V]N9FEG M.PT*#0H)+R]S97)V97(@<V5T=&EN9W,-"@EU;G-I9VYE9"!S:&]R= E?<&]R M=#L-"@EU;G-I9VYE9"!I;G0)7W1I;65O=70[#0H-"G!R:79A=&4Z#0H)8F]O M<W0Z.G!R;V=R86U?;W!T:6]N<SHZ=F%R:6%B;&5S7VUA<"!?=F%R:6%B;&5S M.PT*?3L-"@T*:6YT(&UA:6XH:6YT(&%R9V,L(&-H87(J(&%R9W9;72D@>PT* M"71R>2![#0H)"6]P=&EO;G,@;W!T.PT*"0EO<'0N<F5A9%]O<'1I;VYS*&%R M9V,L(&%R9W8I.PT*"7T-"@EC871C:" H<W1D.CIE>&-E<'1I;VXF(&4I('L- M"@D)<W1D.CIC97)R(#P\(&4N=VAA="@I(#P\('-T9#HZ96YD;#L-"@E]#0H) M8V%T8V@@*"XN+BD@>PT*"0ES=&0Z.F-E<G(@/#P@(F-A=&-H960@=6YK;F]W M;B!E>&-E<'1I;VXB(#P\('-T9#HZ96YD;#L-"@E]#0H)<F5T=7)N(# [#0I] ` end
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