|
Boost : |
From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-01-25 18:15:29
Dietmar Kuehl wrote:
> Basically, template template arguments
> should work like using 'helper' as template argument and using
> 'helper::foo<T>':
>
> struct helper {
> template <typename T> class foo { ... };
> };
>
> That is, the template template arguments didn't add a new feature
> to the language but merely simplified and existing one.
Just an aside [off-topic] note: they (template template parameters ;) didn't
do that well. There are a few useful techniques that can be implemented using
"helpers" classes like the above, but not template template parameters. One
often cited example is something like this:
// 1. using "emulation" technique
struct helper1 {
template<class T> class foo {};
};
struct helper2 {
template<class T1, class T2 = int> class foo {};
};
template<typename TemplateTemplateParam>
struct something {
typename TemplateTemplateParam::template foo<char> foo_;
};
something<helper1> sm1; // ok
something<helper2> sm2; // ok
// 2. using template template parameters
template <class T> class foo1 {};
template <class T1, class T2 = int> class foo2 {};
template<template<class T> class Foo>
struct something {
Foo<char> foo_;
};
something<foo1> sm1; // ok
something<foo2> sm2; // **error**
--Aleksey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk