Is the following valid?:
template<typename T> class C { C1<C2<T>> someMember; };
Is the following valid?:
template<typename T> class C { C1<C2<T>> someMember; };
Well, you'd need to do something with the type, either make it a typedef or member, but yes:
template <typename T>
struct C1 {};
template <typename T>
struct C2 {};
template <typename T>
struct C
{
typedef C1<C2T> > type; // note the space!
};
>>
is actually the right shift operator, so you need a space in there for it to work correctly. In C++0x, however, you can just type >>
; it is parsed just fine.*
*Some lenient compilers will currently accept it.
Erm, no, at least not in isolation, because you have no definition for C1
and C2
. Assuming that they are defined to be template classes with one argument, then no, it's still not valid for the same reason that int;
is not valid -- it's not a complete statement, its just a typename.
Now if you're asking about the syntax with the angle-brackets, then ignoring all of the other issues, that is only valid in C++0x. In the current C++ standard, the parse is ambiguous, and you would have to form it as C1<C2<T> >
.