|
Boost : |
From: John Max Skaller (skaller_at_[hidden])
Date: 2001-06-26 16:05:11
Vesa Karvonen wrote:
> The transformation to remove template template parameters consists of the
> following sub-transformations:
Mind if I try it?
// instance I'll use
template <class T1> class X {
T1 x;
};
// client
template <template<class> class TT>, class T2> class Y {
TT<T2> y;
};
> 1. Every class template (both member templates and namespace templates) is
> wrapped inside a non-template class like this:
>
> // original
> template<...>
> struct an_arbitrary_class_name
> ...
> {...};
>
> // transformed
> struct an_arbitrary_class_name
> {
> template<...>
> struct some_standard_identifier
> ...
> {...};
> };
class X {
template <class T1> class dummy {
T1 x;
};
};
class Y {
template <template<class> class TT, class T2> class dummy {
TT<T2> y;
};
};
> (This transformation obviously stops when all class templates are member
> templates and have the name "some_standard_identifier".)
>
> 2. Every (partial or full) instantiation of a class template is transformed to
> use the "some_standard_identifier" member template:
>
> // original
> an_arbitrary_class_name<...>
>
> // transformed
> an_arbitrary_class_name::/*template*/ some_standard_identifier<...>
class Y {
template<template<class> class TT, class T2> class dummy {
TT::dummy<T2> y;
};
> 3. Every template template parameter is transformed into a type parameter:
>
> (At this point all class templates are named "some_standard_identifier".)
>
> // original
> template<... template<class> class p ...>
> struct some_standard_identifier
> ...
> { ... };
>
> // transformed
> template<... class p ...>
> struct some_standard_identifier
> ...
> { ... };
class Y {
template<class TT, class T2> class dummy {
TT::dummy<T2> y;
};
> This completes the transformation.
Yep. Should work if done globally.
But you've still really got template templates (they're just nested).
You can see this because the above code has an error: the
keyword 'templatename' is required:
templatename TT::dummy<T2> y;
so the parser knows that
TT::dummy
is the name of a template (not a type or variable).
Its worth writing this up as a paper and putting it on boost (at least)
so you can just quote the URL. Nice work: I applied the transformation
easily. (don't forget to fix the bug!)
-- John (Max) Skaller, mailto:skaller_at_[hidden] 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 New generation programming language Felix http://felix.sourceforge.net Literate Programming tool Interscript http://Interscript.sourceforge.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk