2017-10-10 73 views
2

我学习的模板,我觉得这个例子:如何识别部分模板特化

template <typename T, int size> 
void print(StaticArray<T, size> &array) 
{ 
    for (int count = 0; count < size; ++count) 
     std::cout << array[count] << ' '; 
} 


template <int size> 
void print(StaticArray<char, size> &array) 
{ 
    for (int count = 0; count < size; ++count) 
     std::cout << array[count]; 
} 

为什么第二print功能工作,即使它是有non-type参数size,为什么它是完整的模板专业化。

回答