What is template specialization (full vs. partial)?
Last updated
Full specialization fixes all template parameters to exact types (
template<> class X<int>) and works for both class and function templates.Partial specialization matches a pattern or subset (e.g.
X<T*>for all pointers). It is allowed only for class and variable templates, so functions use overloading instead.The compiler picks the most specialized matching version, falling back to the primary template.