On Tue, Jan 20, 2009 at 9:33 AM, Robert Jones <robertgbjones@gmail.com> wrote:

This one IS tested!


#include "boost/lambda/lambda.hpp"
#include "boost/lambda/bind.hpp"
#include <vector>
#include <numeric>
#include <iostream>


struct A{
 int a;
 std::string b;
};

int a_sum(int i, const A &v){ return i + v.a; }

int main( )
{
  using namespace boost::lambda;
  std::vector<A> v;
  for ( unsigned i=1; i != 6; ++i)
  {
    A a = { i, "" };
    v.push_back( a );
  }

  int result = std::accumulate(v.begin(),v.end(),0, _1 + bind(&A::a,_2));
  std::cout << result << "\n";
}
 

What compiler are you using?  Doesn't work on VC 2005 or 2008.  Overload resolution ambiguity failure on boost::lambda::function_adaptor<Func>::apply