Each template instantiation is a separate class of its own. Just as any ordinary class can inherit from whichever base classes you desire, template instantiations can do so as well. Consider the following example:
template <typename Base>
class Derived : public Base
{
};
Absolutely legal...
This is, for instance, the base of the curiously recurring template pattern.
It does not matter if you now decide to implement a specific instantiation differently (so you specialise; or group of, then partially) than the original/main template pattern.
The standard seems to be a little short about the topic:
17.5.1 Class templates [temp.class]
1 A class template defines the layout and operations for an unbounded set of related types.
2 [Example: A single class template List might provide an unbounded set of class definitions: one class List for every type T, each describing a linked list of elements of type T. Similarly, a class template Array describing a contiguous, dynamic array might be defined like this: [ some sample template declaration ]
The prefix template specifies that a template is being declared and that a type-name T may be used in the declaration. In other words, Array is a parameterized type with T as its parameter.
— end example]
[highlighting by me], but uses the same pattern later on when defining type traits:
23.15.3 Helper classes [meta.help]
[definition of integral_constant]
1 The class template integral_constant, alias template bool_constant, and its associated typedef-names true_type and false_type are used as base classes to define the interface for various type traits.
Subsequently, the standard uses the wording "having a base characteristic of", as in:
23.15.4 Unary type traits [meta.unary]
1 This subclause contains templates that may be used to query the properties of a type at compile time.
2 Each of these templates shall be a UnaryTypeTrait (23.15.1) with a base characteristic of true_type if the corresponding condition is true, otherwise false_type.
Together with the previous citation, we can conclude that it is at least legal to inherit from either true_type
or false_type
selectively, according to the condition being fulfilled or not. Difficult to say if this wording even enforces this inheritance or if it is legal as well to define the templates such that they only behave like true_type
and false_type
without explicitly inheriting from (which is another matter, though...).
Not authoritative, of course, I personally tend to the former interpretation due to the preceding "are used as" (in contrast to "can be used as").