class Foo
{
double f1( int x, std::string s1 );
double f2( int x, SomeClass s2 );
}我希望能够在没有foo实例的情况下绑定foo.f1的s1来创建essense
typedef double (Foo::* MyFooFunc)( int )
MyFooFunc func1 = boost::bind( &Foo::f1, _1, _2, "some string" );
MyFooFunc func2 = boost::bind( &Foo::f2, _1, _2, SomeClass );然后我将func1和func2作为参数传递给其他函数,最终将Foo绑定到这些函数中:
void SomeOtherFunction( MyFooFunc func )
{
Foo foo;
boost::function< double (int) > finalFunc =
boost::bind( func, foo, _1 );
}问题:这是可能的吗?如果是,1)如何实现? 2) MyFooFunc的声明是什么?
发布于 2011-08-05 22:32:26
试试这个:
boost::bind(&Foo::f1, object, _1, _2);object是类Foo的一个实例。_1和_2是参数占位符。
https://stackoverflow.com/questions/6957929
复制相似问题