Boost logo

Boost Users :

Subject: [Boost-users] [mpl] simple mpl::transform with placeholder?
From: Andrew King (eurokang_at_[hidden])
Date: 2014-09-19 01:10:42


Hi,

Lets say I have an mpl vector defined as :

template <typename Traits>
struct A
{
};

template <typename Traits>
struct B
{
};

typedef mpl::vector<A<mpl::_>, B<mpl::_> > MyVec;

struct MyTraits {};

How do I 'apply' or transform MyVec with MyTraits?

ie. I want the mpl::vector ...

boost::mpl::vector<A<MyTraits>, B<MyTraits>>;

I realise I can do mpl::apply<A<mpl::_>, MyTraits> to get A<MyTraits> but I
can't work out how to do the equivalent to the entire vector.

mpl::transform seems like what I should be using. Transform seems to do
apply internally, but I can't work out the syntax to do something like:
using substituted = typename boost::mpl::transform<MyVec,
boost::mpl::apply<boost::mpl<_>, MyTraits> >::type;
(This isn't right!)
It may be I am confused because inside the transform, boost::mpl::_1 is the
item in the vector, not the 'inner' placeholder.
Sorry if this is a basic question ...

Regards,
Andrew



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