|
Boost Users : |
Subject: Re: [Boost-users] [program_options] How to use "notifier" in options_description with member functions?
From: jiangzuoyan_at_[hidden]
Date: 2010-10-24 22:01:02
try this with boost::bind
("option", po::value<int>()->notifier(
boost::bind(&test::function, this, _1)), "Option")
Changsheng Jiang
On Mon, Oct 25, 2010 at 06:06, Carlos Franke
<carlos_franke_at_[hidden]>wrote:
> Hello!
>
> I am looking for advice about the use of the "notifier" function in
> program_options::options_description with class methods. My problem seems
> very basic to mee, yet I wasn't able to find the (any) related
> documentation.
>
> Here is a minimal example of what I cannot get to work:
>
> struct test
> {
> void function(int i) {std::cout << i << std::endl;}
>
> void does_not_compile()
> {
> po::options_description desc;
> desc.add_options()
> ("option", po::value<int>()->notifier(&test::function),
> "Option")
> ;
> }
> };
>
> Compilation fails with:
> [â¦]
> test.cpp:62:82: instantiated from here
> /usr/include/boost/function/function_template.hpp:225:11: error: no match
> for call to '(boost::_mfi::mf1<void, test, int>) (const int&)'
> /usr/include/boost/bind/mem_fn_template.hpp:163:7: note: candidates are: R
> boost::_mfi::mf1<R, T, A1>::operator()(T*, A1) const [with R = void, T =
> test, A1 = int]
> /usr/include/boost/bind/mem_fn_template.hpp:184:7: note: R
> boost::_mfi::mf1<R, T, A1>::operator()(T&, A1) const [with R = void, T =
> test, A1 = int]
>
> Sorry if this is trivial. Your help is all the more appreciated!
>
> Carlos
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net