कुछ स्लाइडों से अधिक भार बनाम:खाका समारोह विशेषज्ञता टेम्पलेट विशेषज्ञता के बारे में
#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
क्या ये स्लाइड ऑनलाइन उपलब्ध हैं? –
@ वॉन एक ड्रॉपबॉक्स फ़ोल्डर में ... – nodwj