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@taunusstein.net> 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@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users