One of the possible forms of template parameter is a class template. The C++ standard (C++2003) states that an argument for a template template parameter during the template instantiation is an “id-expression”. This non-terminal is rather wide. It allows destructors, overloaded operators, etc. For example the following code should compile fine:
template <template <typename x> class T>
struct MyClass
{
T<int> a;
T<double> b;
};
template <typename x> struct Helper
{
~Helper() { }
x operator+(x p) { return(x[1]+p); }
x[4] c;
};
MyClass<Helper> p1;
MyClass<~Helper> p2;
MyClass<Helper::operaror+> p3;
The last 2 lines do not make any sense. But from the standpoint of the grammar they are fine. The grammar is not (and should not) describe the language exactly, but the paragraph 14.3.3, “Template template argument” does not mention any restrictions on the grammar rules in this context.
Can anybody embrace or refute my statements:
- Template template argument can be ONLY an identifier, maybe qualified.
- If point one is true, this is definitely worth mentioning in the standard.
14.3 [temp.arg] p1
The argument
~Helperdoes not have the right type for the template template parametertemplate<typename> class T, it’s not a class template.14.3.3 [temp.arg.template] p1
~Helperis not the name of a class template.That pretty clearly rules out your examples.