Von einigen Dias über Template-Spezialisierung Überlastung:Template Funktion Spezialisierung vs.
#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;
}
*/
Warum ist der zweite Weg, um mehr „angemessen“?
Relevante Lektüre: [Warum nicht spezielle Funktionsvorlagen?] (Http://www.gotw.ca/publications/mill17.htm) – juanchopanza
Sind diese Folien online verfügbar? –
@Vaughn In einem Dropbox-Ordner ... – nodwj