cpp/language/member template

Template declarations can appear inside a  of any class, struct, or union that aren't es.

Partial specializations of member template may appear both at class scope and at enclosing namespace scope. Explicit specializations may appear in any scope in which the primary template may appear.

If the enclosing class declaration is, in turn, a class template, when a member template is defined outside of the class body, it takes two sets of template parameters: one for the enclosing class, and another one for itself:

Member function templates
Destructors and copy constructors cannot be templates. If a template constructor is declared which could be instantiated with the type signature of a, the implicitly-declared copy constructor is used instead.

A member function template cannot be virtual, and a member function template in a derived class cannot override a virtual member function from the base class.

A non-template member function and a template member function with the same name may be declared. In case of conflict (when some template specialization matches the non-template function signature exactly), the use of that name and type refers to the non-template member unless an explicit template argument list is supplied.

An out-of-class definition of a member function template must be equivalent to the declaration inside the class (see for the definition of equivalency), otherwise it is considered to be an overload.

Conversion function templates
A user-defined can be a template.

During, specializations of conversion function templates are not found by. Instead, all visible conversion function templates are considered, and every specialization produced by (which has special rules for conversion function templates) is used as if found by name lookup.

Using-declarations in derived classes cannot refer to specializations of template conversion functions from base classes.

{{rrev|since=c++14|

Member variable templates
A variable template declaration may appear at class scope, in which case it declares a static data member template. See s for details. }}