Hello All !
Please tell, can I create nullary functor returning predefined value, using
boost::function & boost::bind ?
Example uses "portable" syntax of boost::function :
#include
#include
struct InterfaceA;
InterfaceA *getInterface ();
template<typename T>
T forward ( T t )
{
return t;
}
int main ( int, char ** )
{
typedef boost::function0 functor_type;
// Value of InterfaceA * supplied by getInterface () function. Usage is
straightforward :
functor_type f1 = boost::bind ( getInterface );
InterfaceA *p = NULL;
// Value of InterfaceA * is known here. How to create functor, returning it
?
// functor_type f2 = boost::bind ( ??? );
// Possible workaround. Can I do this without forward<> template function
?
functor_type f3 = boost::bind ( &forward, p );
return 0;
}
Thanks!
Yuri.