为什么这段代码无法用 VS 2005 编译:
#include <boost/bind.hpp>
#include <boost/function.hpp>
struct X
{
typedef std::auto_ptr<int> IntType;
// typedef int IntType; // this works
IntType memfunc () const
{
return IntType ();
}
X ()
{
boost::bind (&X::memfunc, this);
}
};
出现此警告和错误:
1>j:\libraries\boost\boost_1_37_0\boost\bind.hpp(1643) : warning C4180: qualifier applied to function type has no meaning; ignored
1> j:\libraries\boost\boost_1_37_0\boost\bind.hpp(1677) : see reference to class template instantiation 'boost::_bi::add_cref<Pm,I>' being compiled
1> with
1> [
1> Pm=std::auto_ptr<int> (__thiscall X::* )(void),
1> I=1
1> ]
1> j:\dev\test\test\listtest.cpp(16) : see reference to class template instantiation 'boost::_bi::dm_result<Pm,A1>' being compiled
1> with
1> [
1> Pm=X::IntType (__thiscall X::* )(void),
1> A1=X *
1> ]
?
将 IntType typedef 更改为只是一个 int 允许它编译。