0

我有一个代码片段如下:

#include <boost/bind.hpp>
#include <boost/lambda/bind.hpp>
......................
...................
size_t MyCalass::MyFunction() const
{
   using boost::lambda::_1;
   using boost::lambda::_2;
   using boost::lambda::bind;

   return std::accumulate(m_memberObj.begin(), m_memberObj.end(),
      size(), (_1 += bind(&MyCalass::GetLength, _2)));
}

在这里,毫无疑问, boost::lambda::bind 调用写在函数的最后一行。但我得到编译错误。它看起来像这样:

Error   70  error C2784: 'const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::arithmetic_assignment_action<Action>,boost::tuples::tuple<boost::lambda::lambda_functor<T>,boost::lambda::lambda_functor<Arg>>>> boost::lambda::operator +=(const boost::lambda::lambda_functor<T> &,const boost::lambda::lambda_functor<Arg> &)' : could not deduce template argument for 'const boost::lambda::lambda_functor<T> &' from 'stlp_std::basic_string<_CharT,_Traits,_Alloc>::size_type'   z:\3rdParty\boost_1_41_0_patched\boost\lambda\detail\operator_lambda_func_base.hpp  225

当我像这样更改我的代码时:

#include <boost/bind.hpp>
#include <boost/lambda/bind.hpp>
......................
...................
size_t MyCalass::MyFunction() const
{
   using boost::lambda::_1;
   using boost::lambda::_2;
   using boost::lambda::bind;

   return std::accumulate(m_memberObj.begin(), m_memberObj.end(),
      size(), (_1 += boost::lambda::bind(&MyCalass::GetLength, _2)));
}

它编译正确。

这是编译器错误吗?这个有补丁吗??

4

0 回答 0