Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-12-18 06:28:40


Peter Dimov wrote:
> From: "David Abrahams" <david.abrahams_at_[hidden]>
> > You have to ask Aleksey for his rationale, but AFAIK
> > template template parameters are much less flexible.
> > For example, how do you write a compile-time bind2nd
> > if metafunctions are templates?
>
> Aha, the missing typedef template.
>
> I wonder, did anyone see my (half-serious) comp.std.c++
> proposal to turn templates into:
>
> template<A, B, C> class X;
>
> (partly motivated by the similarity between type list
> algorithms and value list algorithms.)

Expression template templates :) allow you to have something like this
without a core language change (although the technique has its limitations).

For example, instead of

    template<template<typename T> class P > struct A
    {
        typedef P<A> something;
    };
    
you just write

    template<typename P > struct A
    {
        typedef typename boost::mpl::expr_templ<P>::type p_f;
        typedef typename p_f::template apply<A>::type something;
    };

and in user code instead of

    template<typename T> struct her_templ { /* ... */ };
    A<her_templ> a;

one writes:

    template<typename T> struct her_templ { /* ... */ };
    A< her_templ<_1> > a;

    template<typename T1, typename T2> struct another_her_templ { /* ... */
};
    A< her_templ<int,_1> > a2;

    // etc.

Aleksey


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