
Aljaz wrote:
Hello
I have boost.program_options implemented inside a config class.
I want to call function (my_function) that is a member of config class for specific option (with notifier call).
class config_class { public: void read_config() { po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") ("include-path,I", po::value< vector<string>
()->notifier(&config_class::my_function), "include path"); }
void my_function(vector<std::string> str) { }
Don't pass vector by value. Further, the notifier method is documented thusly: typed_value * notifier(function1< void, const T & > f) ; Specifies a function to be called when the final value is determined. So you better make the parameter const -- you won't be able to modify it anyway.
};
This wont compile and will give error for ..>()->notifier(&config_class::my_function)...
error C2064: term does not evaluate to a function taking 1 arguments
What am I doing wrong?
You are passing function with two parameters ("this" and "str") where a function taking one parameter is expected. Use: boost::bind(&config_class::my_function, this) - Volodya