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:56:03


On Tue, Apr 5, 2011 at 2:27 PM, Peter Dimov <pdimov_at_[hidden]> wrote:

>
> using boost::lambda::bind;
>
> should be a better choice.
>
>
Hello Peter

Yes, that was my first thought too. But this code still has ambiguity
issues.

#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( )
{
    using boost::lambda::bind;

    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 ) ) );
}

Thx

- Rob.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net