|
Boost Users : |
Subject: Re: [Boost-users] Boost.MPL: Is it possible to apply a variable substitution without evaluating the lambda-expression?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-27 16:46:11
AMDG
Luke Simon wrote:
> I am using BOOST_MPL_ASSERT to assert a lambda-expression applied to a
> sequence of types by folding the lambda-expression onto a sequence of
> types (see code and continue discussion below).
>
> template<class predicate, class argument> struct mpl_assert
> {
> typedef typename apply<predicate, argument>::type type;
> BOOST_MPL_ASSERT((type));
> };
>
> template<class pred, class xs> struct assert_for_all : foldr<
> mpl_assert<typename lambda<pred>::type, _>,
> true_,
> xs
>
>> {};
>>
>
>
> <snip>
>
> ...but what I want to have printed is the type:
>
> boost::is_same<foo, bar>
>
>
> Boost.MPL is already calculating such a type, because apply<is_same<foo,
> _>, bar> returns is_same<foo, bar>::type, so the needed type is there...
> but does Boost.MPL provide a means of accessing it as opposed to
> accessing its ::type field?
>
MPL doesn't provide such a metafunction. Note that MPL doesn't
actually calculate this in the process of evaluating lambda expressions,
because
of nesting. For example, is_same<foo, remove_reference<_> > does not
ever use is_same<foo, remove_reference<bar> >
You might try using protect instead of lambda in assert_for_all.
In Christ,
Steven Watanabe
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