Boost logo

Boost Users :

Subject: [Boost-users] [mpl] Using max_element inside a fold while constructing a vector
From: Brendon Costa (brendon.j.costa_at_[hidden])
Date: 2013-05-29 23:55:59


Hi,

I have been using boost.mpl for the first time recently and have solved a
number of tasks with boost.mpl now but have a problem with a bit of code I
thought should be working.

What is wrong with this bit of code using boost.mpl?

typedef vector<int_<0>, int_<3>, int_<2> > v1;

// I want to use max_element on a vector I am in the process of
constructing using a fold
typedef typename fold<v1, vector<int_<0> >, push_back<_1,
deref<max_element<_1>::type >::type> >::type v2;

// This code below compiles and runs fine to illustrate that max_element on
a vector works, but is not what I am after.
// I thought _1 in the max_element above would be a vector just as v1 below
is, but the one below works and the one above does not.
// typedef typename fold<v1, vector<int_<0> >, push_back<_1,
deref<max_element<v1>::type >::type> >::type v2;

I know this code is only going to create v2 like [0, 0, 0, 0] in this case
but this is a smaller part of a larger expression that is failing and I cut
it down to the minimum to show the problem at hand.

In case it is useful I am using gcc 4.5.3 and boost 1.50



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