[cfe-dev] Passing type template as template template parameter within its own definition
Mario Schwalbe
mario at se.inf.tu-dresden.de
Thu Apr 18 02:52:08 PDT 2013
Hi,
I recently came across some template code, which essentially boils
down to something like this:
template <template <typename> class T>
struct TakeIt
{
typedef T<long> Type;
};
template <typename T>
struct Test
{
typedef TakeIt<Test>::Type Fails;
};
typedef TakeIt<Test>::Type Works;
The last typedef works fine passing Test as a template template parameter to
annother template TakeIt. However, doing the same within the definiton of
Test fails to compile with clang 3.2:
PassSelf.cpp:10:20: error: template argument for template template parameter must be a class
template
typedef TakeIt<Test>::Type Fails;
I do understand that within the definiton of a type template its name may
be used to refer to its own instantiation and the corresponding long version
typedef TakeIt< Test<T> >::Type Fails;
is wrong. So it's at least ambiguous. On the other hand, it compiles fine with GCC
(both compilers in C++98 mode). So who is right? Or am I just missing some
fancy template syntax, I don't know yet.
Thanks & ciao,
Mario
More information about the cfe-dev
mailing list