I have read docs about Explicit Specialization of Class Templates and Partial Specialization of Class Templates, but don't understand what kind of specialization is used in this example (msdn links are used only due to my current environment, the question is more or less theoretical). I need the name used in c++ standard and/or links for documentation or reference to c++ standard paragraphs. The problem I'm trying to solve is quite complex to ask directly, but I have an idea how to use a similar aproach to the one used in this sample.
template<class T>
struct is_vector {
static bool const value = false;
};
template<class T>
struct is_vector<std::vector<T>> {
static bool const value = true;
};
This defines a (primary) class template is_vector<T>
, and then partially specialises it for T = std::vector<U>
.
The general rule is fairly simple:
Primary template:
template <something here> class someName /*no angle barckets here */ { ... }
Partial specialisation:
template <something here> class someName<otherThing here> { ... }
Explicit specialisation:
template <> class someName<something here> { ... }
There is no short piece of the standard to cite, but you can refer to the subchapter C++11[temp.class.spec]
. There is nothing in that chapter that would restrict partial specialisations to pointers and references. Note that the MSDN link you gave does not limit its scope to them either; it says "such as" before the examples, which does not mean there are no other possibilities.