What this C++ template specialization question tests
This is a medium-difficulty C++ language-knowledge question that probes your understanding of template specialization and how the compiler resolves which template instantiation to use. It rewards careful reading of template definitions and a solid grasp of specialization precedence.
To work through problems like this, you need to trace through the template matching process: identify candidate templates, determine which specializations apply, and understand the order in which the compiler picks among them. The question typically hinges on distinguishing between primary templates, partial specializations, and explicit specializations—and recognizing subtle differences in how each matches a given type or expression.
- Primary template definitions and their instantiation
- Partial template specialization and matching rules
- Explicit (full) template specialization
- Specialization precedence and overload resolution