Why can't you define a pattern with structure?
is just a keyword indicating what
the type is. It doesn't really mean that there
should be a class. (for example, you can call
The keyword was used
didn't exist when the template function was added. See Templates in C ++, typename and class .
source to share
Because the grammar forbids it:
template-declaration: export_opt template< template-parameter-list > declaration template-parameter-list: template-parameter parameter-declaration type-parameter: class identifier class identifier = type-id typename identifier typename identifier = type-id template < template-parameter-list > class identifier template < template-parameter-list > class identifier = template-name
Alternatively, you can think of a struct as a special case of a class in which all members are public. Thus, including this parameter in the list of template parameters will not be as general.