|
Boost Users : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2005-02-02 06:59:18
Vyacheslav E. Andrejev writes:
>
> I want to parametrize mpl::transform to form a new metafunction. But
> I have confused with mpl syntax and notations. Imagine, I have
> following vector
>
> typedef boost::mpl::vector<Type1, Type2, Type3, Type4> types;
>
> and following transformation:
>
> typedef boost::mpl::transform<
> types
> , boost::is_convertible<Type3, boost::mpl::_1>
> >::type result;
>
> The result of the tansformation is a bool vector that indicates
> whether Type3 is convertible to any of type from types vector. Now I
> want to form metafunction that will construct such array not from
> Type3, but from its argument. Of course, I may use straightforward
> method:
>
> struct WhoConverted
> {
> template <typename ConversionType>
> struct apply
> {
> typedef typename boost::mpl::transform<
> types
> , boost::is_convertible<ConversionType, boost::mpl::_1>
> >::type type;
> };
> };
Or
template< typename T > struct WhoConverted
: boost::mpl::transform<
types
, boost::is_convertible<T, boost::mpl::_1>
>
{
};
>
> But it seems more like workaround rather than solution.
It's inconvenient to have to write (and name) an auxiliary template
that has no other uses, yes.
> Can it be
> done in more convenient and short manner by means of all mpl
> machinery like mpl::lambda, mpl::bind, placeholders, etc... ?
At the moment, the above is the best you can have. I'm considering
implementing lambda scoping along the lines of
http://article.gmane.org/gmane.comp.lib.boost.devel/116000 for the
next release.
HTH and sorry for the late reply,
-- Aleksey Gurtovoy MetaCommunications Engineering
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