Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a place where C++03 and C++11 are different from each other. The relevant part of the standard is <code>[temp.local]/1</code>. In C++03, this states:</p> <blockquote> <p>Like normal (non-template) classes, class templates have an injected-class-name (clause 9). The injected-class-name can be used with or without a template-argument-list. When it is used without a template- argument-list, it is equivalent to the injected-class-name followed by the template-parameters of the class template enclosed in &lt;>. When it is used with a template-argument-list, it refers to the specified class template specialization, which could be the current specialization or another specialization.</p> </blockquote> <p>This means that <code>child</code> (without any template arguments) refers to the specialization <code>child&lt;V&gt;</code>. In C++11, it was changed to:</p> <blockquote> <p>Like normal (non-template) classes, class templates have an injected-class-name (Clause 9). The injected- class-name can be used as a template-name or a type-name. When it is used with a template-argument-list, as a template-argument for a template template-parameter, or as the final identifier in the elaborated-type-specifier of a friend class template declaration, it refers to the class template itself. Otherwise, it is equivalent to the template-name followed by the template-parameters of the class template enclosed in &lt;>.</p> </blockquote> <p>Note in particular <code>When it is used ... as a template-argument for a template template-parameter ... it refers to the class template itself.</code>. This means that in C++11, your code would be correct.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload