Boost logo

Boost Users :

Subject: [Boost-users] [MPL] Fold a vector of pairs
From: Peter Nyssen (peter_at_[hidden])
Date: 2012-03-14 11:10:36

Removing the typename before mpl::fold fixes it.

Kind regards,


#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/vector.hpp>

namespace mpl = boost::mpl;

struct tag1 {};
struct tag2 {};

template <typename T>
struct is_tag1 : boost::false_type {};

template <>
struct is_tag1<tag1> : boost::true_type {};

int main()
    typedef mpl::vector<
        mpl::pair<tag1, mpl::int_<1> >,
        mpl::pair<tag2, mpl::int_<2> >,
        mpl::pair<tag1, mpl::int_<3> >
> initial_vector;

    typedef mpl::fold<
        mpl::pair<mpl::vector<>, mpl::vector<> >,
            is_tag1<mpl::first<mpl::_2> >,
>::type sorted_pair;

    return 0;

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