[Boost-bugs] [Boost C++ Libraries] #8608: Default lambda expression with mpl::equal

Subject: [Boost-bugs] [Boost C++ Libraries] #8608: Default lambda expression with mpl::equal
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-22 21:25:01

#8608: Default lambda expression with mpl::equal
 Reporter: Louis Dionne <ldionne.2@…> | Owner: agurtovoy
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: mpl
  Version: Boost Development Trunk | Severity: Problem
 Keywords: default lambda mpl equal |
 Summary of the original message posted on the mailing list:

 Some higher order algorithms in the MPL have a default for the lambda
 expression they accept. A good example is `boost::mpl::equal`:
     template <typename S1, typename S2, typename Pred = is_same<_, _> >
     struct equal;

 This works fine most of the time, but I was recently bitten by the

     template <typename VectorOfVectors, typename Vector>
     struct find_vector
         : find_if<
             VectorOfVectors, equal<Vector, _1>
     { };

     typedef find_vector<
             vector<int, int>,
             vector<char, char>
         vector<char, char>
>::type ThisWillBreak;

 What happens here is that the `equal<Vector, _1>` expression inside
 `find_vector` really is `equal<Vector, _1, is_same<_1, _2> >` because
 of the default value for the predicate to `equal`. When the lambda is
 evaluated, the placholders inside the inner `is_same<_1, _2>` expression
 are replaced too, which yields unexpected results.

 Original thread:

Ticket URL: <https://svn.boost.org/trac/boost/ticket/8608>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC