Home > Blockchain >  C Templates: Explicit specialization vs Complete specialization. Is it the same thing?
C Templates: Explicit specialization vs Complete specialization. Is it the same thing?

Time:12-17

In microsoft's documentation https://learn.microsoft.com/en-us/cpp/cpp/templates-cpp?view=msvc-170#template-specialization, it is said that Specializations in which all parameters are specialized are complete specializations.

but I also hear the cpp reference talking about explicit specialization here: https://en.cppreference.com/w/cpp/language/template_specialization

Are "explicit specialization" and "complete specialization" two different terminology for the same thing?

CodePudding user response:

It seems that they are referring to explicit specialzations, which is the term used in the standard. The term full specialization is also common.

The technical term explicit specialization may not be a good choice because the word explicit already is very overloaded. For example it can easily be confused with explicit instantiation or the explicit keyword.

The difference between explicit (or full/complete) specializations and partial specializations is however important and not just a matter of giving a specific variant of partial specialization an additional name. In contrast to a partial specialization, an explicit (or full/complete) specialization is not itself a template. So it basically follows all the rules of non-templates, including e.g. how inline and the ODR rule is applied. An explicit specialization also doesn't require any instantiation.

  • Related