
On 3/29/06, Nico Galoppo
Hi,
what kind of object does boost::bind return when binding to a class member variable ? (as opposed to a member method). Is it a function object too?
More in particular, I would like to write a generic free function that applies an operation on a particular member variable, passed in with boost::bind. Something like this:
struct A { int value; };
void f(bind_return_type& membervar) { membervar = 3; }
A a; f(bind(&A::value, a));
Thanks.
--nico
Couldn't you just do void f(int& membervar) { membervar = 3; } A a; f(a.value); ? To get back to bind return types - they're not simple. Your best bet is to use boost::function to hold the result of boost::bind if you want to keep it around. Just make sure any variables involved are still alive when the function is eventually invoked. Stuart Dootson