【发布时间】:2012-03-15 16:50:21
【问题描述】:
我有以下代码:
int MimeDocument::GetAttachmentId( std::string const& content_id )
{
using namespace boost::lambda;
using boost::lambda::_1;
using boost::bind;
int id = 0;
std::vector<std::string>::iterator it =
std::find_if( attachment_list_.begin(), attachment_list_.end(),
bind( &std::string::find, content_id, _1 ) != std::string::npos
);
if( it != attachment_list_.end() ) {
id = std::distance( attachment_list_.begin(), it );
}
return id;
}
在 MSVC9 SP1 上编译时会导致大量 C2780 编译器错误。以下只是列表顶部的几个:
1>c:\code\work\cmake-mds\server\gmmserver\domino\server\interface\dimime.cpp(210) : error C2780: 'boost::_bi::bind_t<_bi::dm_result<MT::* ,A1>::type,boost::_mfi::dm<M,T>,_bi::list_av_1<A1>::type> boost::bind(M T::* ,A1)' : expects 2 arguments - 3 provided
1> c:\code\work\cmake-mds\build-vc9\third_party\boost\1.48.0\include\boost\bind\bind.hpp(1728) : see declaration of 'boost::bind'
1>c:\code\work\cmake-mds\server\gmmserver\domino\server\interface\dimime.cpp(210) : error C2780: 'boost::_bi::bind_t<Rt2,boost::_mfi::cmf8<R,T,B1,B2,B3,B4,B5,B6,B7,B8>,_bi::list_av_9<A1,A2,A3,A4,A5,A6,A7,A8,A9>::type> boost::bind(boost::type<T>,R (__thiscall T::* )(B1,B2,B3,B4,B5,B6,B7,B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 3 provided
1> c:\code\work\cmake-mds\build-vc9\third_party\boost\1.48.0\include\boost\bind\bind_mf2_cc.hpp(223) : see declaration of 'boost::bind'
1>c:\code\work\cmake-mds\server\gmmserver\domino\server\interface\dimime.cpp(210) : error C2780: 'boost::_bi::bind_t<Rt2,boost::_mfi::mf8<R,T,B1,B2,B3,B4,B5,B6,B7,B8>,_bi::list_av_9<A1,A2,A3,A4,A5,A6,A7,A8,A9>::type> boost::bind(boost::type<T>,R (__thiscall T::* )(B1,B2,B3,B4,B5,B6,B7,B8),A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 11 arguments - 3 provided
1> c:\code\work\cmake-mds\build-vc9\third_party\boost\1.48.0\include\boost\bind\bind_mf2_cc.hpp(212) : see declaration of 'boost::bind'
任何与 boost 相关的编译器错误对我来说几乎是不可读和无益的,所以我希望有人能帮助我弄清楚发生了什么。提前致谢。
【问题讨论】:
-
获取标准库(成员)函数的地址是非法的;我不知道您为什么忽略了对上一个(已删除)问题的评论。
-
@ildjarn 2 个原因:1)我发的太早了;我的代码很垃圾,2)您没有解释原因(没有引用标准等)。此外,您的评论没有解决编译器失败的原因,即使它是非法的,我仍然想知道原因。
-
有 4 个不同的
std::string::find。编译器应该选择哪一个? -
@Robert :关于 2),我并没有试图回答你的问题(因此发表评论而不是答案),我只是指出你想要实现的是无论如何都失败了。
-
@ildjarn 我说过“......而且你的 comment 没有解决......”。而且,无论您选择哪种方式来解决我的问题,您都还没有在推理背后展示任何类型的事实。
标签: c++ boost stl compiler-errors boost-bind