C++相談室 part60at TECH
C++相談室 part60 - 暇つぶし2ch221:デフォルトの名無しさん
08/01/27 13:21:55
template <typename T> //primary template
class Test {
public:
 enum { Result = 1 };
};

template <typename T> //T const に対する partial specialization
class Test<T const> {
public:
 enum { Result = 2 };
};

template<typename T>
void f(T t)
{
 cout << Test<T>::Result << endl;
}

int main()
{
 int i = 1;
 f(i); // ① --> 1が表示される

 int const j = 1;
 f(j); // ② --> 1が表示される

}




次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch