partial-specialization

(Partially) specializing a non-type template parameter of dependent type

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 13:03:18
问题 Maybe I\'m tired, but I\'m stuck with this simple partial specialization, which doesn\'t work because non-type template argument specializes a template parameter with dependent type \'T\' : template <typename T, T N> struct X; template <typename T> struct X <T, 0>; Replacing 0 by T(0) , T{0} or (T)0 doesn\'t help. So is this specialization even possible? 回答1: See paragraph [temp.class.spec] 14.5.5/8 of the standard: The type of a template parameter corresponding to a specialized non-type

C++ function template partial specialization?

女生的网名这么多〃 提交于 2019-11-26 12:57:03
I know that the below code is a partial specialization of a class: template <typename T1, typename T2> class MyClass { … }; // partial specialization: both template parameters have same type template <typename T> class MyClass<T,T> { … }; Also I know that C++ does not allow function template partial specialization (only full is allowed). But does my code mean that I have partially specialized my function template for one/same type arguments? Because it works for Microsoft Visual Studio 2010 Express! If no, then could you please explain the partial specialization concept? #include <iostream>