【发布时间】:2013-05-02 18:46:11
【问题描述】:
有问题的代码:
boost::function<bool()> isSpecialWeapon = boost::bind(&WeaponBase::GetType,this) == WeaponType::SPECIAL_WEAPON;
我得到的错误是这样的:
undefined reference to `boost::_bi::bind_t<bool, boost::_bi::equal,
boost::_bi::list2<boost::_bi::bind_t<WeaponType::Guns,
boost::_mfi::cmf0<WeaponType::Guns, WeaponBase>,
boost::_bi::list1<boost::_bi::value<WeaponBase*> > >,
boost::_bi::add_value<WeaponType::Guns>::type> > boost::_bi::operator==
<WeaponType::Guns, boost::_mfi::cmf0<WeaponType::Guns, WeaponBase>,
boost::_bi::list1<boost::_bi::value<WeaponBase*> >, WeaponType::Guns>
(boost::_bi::bind_t<WeaponType::Guns, boost::_mfi::cmf0<WeaponType::Guns, WeaponBase>,
boost::_bi::list1<boost::_bi::value<WeaponBase*> > > const&, WeaponType::Guns)'
【问题讨论】:
-
你到底想完成什么?
-
@EmileCormier 尝试创建一个函数来确定当前对象是否属于 X 类型,因为它可以是 {X,Y,Z} 类型
-
你愿意/能够使用 C++11 的特性吗?
-
@EmileCormier 抱歉,我正在使用的系统不支持 C++11,否则我会使用 lamdas。你能告诉我我是否读错了文档boost.org/doc/libs/1_53_0/libs/bind/bind.html#operators
-
你用的是什么编译器?从文档看来,它应该可以工作。因为与值比较的绑定函子应该返回一个新的绑定函子来进行比较。
标签: c++ templates boost linker boost-bind