【发布时间】:2011-10-24 01:37:41
【问题描述】:
除非从类的构造函数中调用,否则为什么使用以下语句会失败?
updateState = boost::bind( &PhysicsObject::updateActive, this );
但是,以下在运行时失败,出现“what(): call to empty boost::function”异常
void PhysicsObject::setState( PhsyicsObjectState aState ) {
_state = aState;
if( _state == ACTIVE ) { // This branch is executed
updateState = boost::bind( &PhysicsObject::updateActive, this );
} else {
updateState = boost::bind( &PhysicsObject::updateExploding, *this );
}
}
【问题讨论】:
-
第二个
bind调用中的*this看起来很可疑 -
你说得对,我只是在进去的时候才这样设置的——让我试试这个或那个。