在C ++模板的上下文中,专门化和实例化有什么区别?从我到目前为止所读到的内容来看,以下是我对专门化和实例化的理解。
编译器实例化
我的理解中,模板实例化和特化的正确性如何?
template <typename T>
struct Struct
{
T x;
};
template<>
struct Struct <int> //specialization
{
//code
};
int main()
{
Struct <int> s; //specialized version comes into play
Struct <float> r; // Struct <float> is instantiated by the compiler as shown below
}
编译器实例化
Struct <float>
template <typename T=float>
struct Struct
{
float x;
}
我的理解中,模板实例化和特化的正确性如何?