Boost logo

Boost Users :

Subject: [Boost-users] mpl::find_if / placeholder question
From: vasyl_y (vasyl.yarmamedov_at_[hidden])
Date: 2009-05-09 14:28:37


I started learn mpl and here we go...
I have an mpl::vector of compund types and i want to find an element in
vector based on
property of compound type and cannot find the way to do it, any suggestions?
Here is an example how i'm trying to do it:

#include <boost/mpl/vector.hpp>
#include <boost/mpl/find_if.hpp>
#include <boost/type_traits.hpp>

namespace mpl = boost::mpl;

template<typename T, int id>
struct Type2IdLink {
  typedef T value_type;
  typedef mpl::int_<id> type_id;

typedef Type2IdLink<char, 1> v1;
typedef Type2IdLink<int, 2> v2;
typedef Type2IdLink<unsigned, 3> v3;

typedef mpl::vector<v1, v2, v3> types;
// This work
typedef mpl::find_if<types, boost::is_same<mpl::_1, v2> >::type iter;
// This does not work:
// value_type is not a member of mpl_::_1
typedef mpl::find_if<types, boost::is_same<mpl::_1::value_type, v2> >::type

BOOST_MPL_ASSERT_RELATION( iter::pos::value, == , 1);

Using BOOST version 1.38, GCC4.3.

Thank You

View this message in context:
Sent from the Boost - Users mailing list archive at

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