Boost logo

Boost Users :

Subject: Re: [Boost-users] [Lambda] Handling Bind/Lambda name clashes.
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2011-04-05 09:32:27

Sorry, I should have been clearer. This is exactly the code that doesn't
work for
me, with no namespace qualification of 'bind'.

I'm guessing that the use of a Boost.Function as an argument to bind causes
bind in the boost namespace to be considered, as well the bind in the
namespace which is considered because of the use of Boost.Lambda

I just can't think of a tidy solution.


- Rob.

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/function.hpp>
#include <boost/range.hpp>
#include <vector>
#include <numeric>

// and also this...
#include <boost/bind.hpp>

struct X
    int f( ) const { return 1; }

int sum( int a, int b ) { return a + b; }

int main( )
    boost::lambda::placeholder1_type x;
    boost::lambda::placeholder2_type y;

    std::vector<X> v;

    boost::function<int(int, int)> my_sum = bind( sum, x, y );

    std::accumulate( boost::begin( v ), boost::end( v ), 0, bind( my_sum, x,
bind( &X::f, y ) ) );

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at