我需要将一个成员函数传递给第三方外部方法:
box_self_intersection_d(mycallback);
The box_self_intersection_d
是第三方外部静态方法,我无法修改它。mycallback
是我想将其传递到的方法box_self_intersection_d
,它是一个类函数,正在访问该类中的一些成员(对该类和mycallback
)
无论如何,我可以使用类成员函数作为回调,而不将它们声明为静态函数吗?
编辑:签名mycallback
is (const box &boxA, const box &boxB)
, where box
是来自第三方提供商的特殊类。
And the 签名为 box_self_intersection_d
is
void box_self_intersection_d(RandomAccessIterator begin,RandomAccessIterator end,Callback callback)
如果函数box_self_intersection_d
将函数作为参数,并且mycallback
是一个类的方法MyClass
, 您可以使用boost::bind
:
box_self_intersection_d( boost::bind( &MyClass::mycallback, myClassInstance ) );
where myClassInstance
是类的实例MyClass
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)