On 13-05-21 01:43 PM, Louis Dionne wrote:
Hi,
Some higher order algorithms in the MPL have a default for the lambda expression they accept. A good example is `boost::mpl::equal`:
template
> struct equal; This works fine most of the time, but I was recently bitten by the following:
template
struct find_vector : find_if< VectorOfVectors, equal > { }; typedef find_vector< vector< vector
, vector >, vector >::type ThisWillBreak; What happens here is that the `equal
` expression inside `find_vector` really is `equal >` 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. Using
template
>::type> struct equal; or equivalently
template
> struct equal; fixes the issue. Also note that all of the unit tests of the MPL still pass with these changes. Is the current behavior intended, or should I submit a patch?
I'm not an expert, but it sounds like a bug to me. You should probably file it (http://svn.boost.org) so it doesn't get lost. Assign it to Aleksey Gurtovoy (agurtovoy). A patch certainly couldn't hurt. Even better if it came with a test. :-) -- Eric Niebler Boost.org