C++相談室 part7
■ このスレッドは過去ログ倉庫に格納されています
0027デフォルトの名無しさん
NGNG#include <iostream>
template<typename T> class Test;
template <typename T> bool operator ==(const Test<T>& t1,const Test<T>& t2);
template<> bool operator ==(const Test<int>& t1,const Test<int>& t2);
template<typename T> class Test
{
friend bool operator ==(const Test<T>& t1,const Test<T>& t2);
};
template<> class Test<int>
{
friend bool operator ==(const Test<int>& t1,const Test<int>& t2);
};
template <typename T> bool operator ==(const Test<T>& t1,const Test<T>& t2)
{
std::cout << "template" << std::endl;
return true;
}
template<> bool operator ==(const Test<int>& t1,const Test<int>& t2)
{
std::cout << "specialization for int" << std::endl;
return true;
}
int main()
{
Test<int>() == Test<int>();
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています