I have a Visual Studio 2008 C++03 project where I would like to use a boost::function
object to set the value of a pointer. Something like this:
boost::function< void( int* ) > SetValue;
boost::function< int*() > GetValue;
int* my_value_;
SetValue = boost::bind( my_value_, _1 ); // how should this look?
GetValue = boost::bind( my_value_ ); // and this?
int v;
SetValue( &v );
assert( my_value_ == &v );
int* t = GetValue();
assert( t == my_value_ );
Is there a way to do this or do I need an intermediate function like:
void DoSetValue( int* s, int* v ) { s = v; };
SetValue = boost::bind( DoSetValue, my_value_, _1 );
Thanks