次のコンパイルが行われていることに非常に驚いています。
#include <iostream>
using namespace std;
template<typename T>
class SomeCls {
public:
void UseT(T t) {
cout << "UseT" << endl;
}
};
template<>
class SomeCls<int> {
// No UseT? WTF?!??!?!
};
int main(int argc, char * argv[]) {
SomeCls<double> d;
SomeCls<int> i;
d.UseT(3.14);
// Uncommenting the next line makes this program uncompilable.
// i.UseT(100);
return 0;
}
なぜこれが許可されるのですか?class SomeCls<int>
メソッドを必要としないのは間違っているようvoid UseT(T t)
です。私はここで専門分野を見逃していると確信しています(私はC ++の専門家ではありません)。誰かが私を教えてくれませんか?