Boost logo

Boost Users :

Subject: [Boost-users] [program_options] How to use "notifier" in options_description with member functions?
From: Carlos Franke (carlos_franke_at_[hidden])
Date: 2010-10-24 18:06:34


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 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