Из некоторых слайдов о специализации шаблона:шаблона функция специализация по сравнению с перегрузкой
#include <iostream>
using namespace std;
template<class X>
X& min(X& a, X& b)
{
return a > b ? b : a;
}
int& min(int& a, int & b)
{
// rewrite of the function in the case of int:
cout << "int explicit function\n";
return a > b ? b : a;
}
/*
new syntax – the more appropriate way:
template<>
int& min<int>(int& a, int& b)
{
cout << "int explicit function\n";
return a > b ? b : a;
}
*/
Почему второй путь более «соответствующий»?
Обращаем ваше внимание: [Почему бы не специализировать шаблоны функций?] (Http://www.gotw.ca/publications/mill17.htm) – juanchopanza
Доступны ли эти слайды онлайн? –
@Vaughn В папке с Dropbox ... – nodwj