// template specialization
#include <iostream>
using namespace std;
// class template:
template <class T>
class mycontainer {
T element;
public:
mycontainer (T arg) {element=arg;}
T increase () {
//if(T.type==int)//how to do this or something similar?
//do this if an int
return ++element;
//if(T.type==char)
//if ((element>='a')&&(element<='z'))
//element+='A'-'a';
//return element;
}
};
テンプレートの特殊化を記述し、char型専用にクラス全体のdefを個別に実行する方法を知っています。
しかし、1つのコードブロックですべてを処理したい場合はどうなりますか?
Tがintかcharかを確認するにはどうすればよいですか?