Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-09-19 16:50:56


Richard Crossley wrote:
> Personally I 'get around the problem' with an additional template:
>
> template <typename T>
> struct eva; // evaluate arguments
>
> template <template <typename> class F,typename A0>
> struct eva<F<A0> > : F<typename A0::type>
> {};
> template <template <typename,typename> class F,typename
> A0,typename A1>
> struct eva<F<A0,A1> > : F<typename A0::type,typename A1::type>
> {};
>
> etc... So,
>
> apply_if<some_condition,some_type_1,plus<some_type_2::type,som
> e_number >
> >::type;
>
> Becomes,
>
> apply_if<some_condition,some_type_1,eva<plus<some_type_2,some_number>
> >::type;
>
> Assuming some_number evaluates to its self, or if not,
>
> apply_if<some_condition,some_type_1,eva<plus<some_type_2,ident
> ity<some_n
> umber> > >::type;
>

That's close to what I've been thinking about:

    typedef apply_if<
          some_condition
        , some_type_1
        , lazy< plus< apply0<some_type_2>, some_number > >
>::type f;

Basically, it's just another form of lambda.

Aleksey


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