Boost logo

Boost :

Subject: [boost] Boost MPL metafunction shortcut
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2011-04-09 15:48:57


I was thinking lately that it is a shame we can't do the following :

boost::mpl::transform< SomeSequence, _1&>

instead of the lengthy

boost::mpl::transform< SomeSequence, add_reference<_1> >

same goes for *, const, volatile :

boost::mpl::transform< SomeSequence, volatile _1**&>

Could it be possible to get such a behavior in MPL by having a pass of
replacing type qualifier
by corresponding metafunction until none are left then apply the lambda ?

In the same vein, having a MPL trandform turning a sequence of
std::vector into their corresponding value_type
require out of line small metafunction to be written. I guess a macro like

BOOST_MPL_ADAPTED_PLACEHOLDER( v,
(type)(value_type)(reference)(const_reference) )

builds a whoel familly of _v1, ..., _v5 placeholder which behaves like
_n and expose typedef
called value_type etc ... that resolve to said small lambda function
directly.

This would allow for a terse:

boost::mpl::transform< SomeSequence, _v1::reference>

Are these ideas out of the question due to some internals of MPL I
missed ? Are they worthy a patch ?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk