Reputation: 2576
I am studying templates where I find this example :
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];
}
Why second print
function works even though it is having non-type
parameter size
and why it is full template specialization.
Upvotes: 2
Views: 30
Reputation: 172924
No, this is not specialization, but function template overloads, which take different template parameters.
As you said, the 2nd overload still has a template parameter, so it's not a full specialization. And partial specialization is not allowed for function template; it only works with class templates.
Upvotes: 1