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