아랫글의 내용을 살짝 비튼거다.


#include <iostream>

#include <typeinfo>

using namespace std;


template<typename T>

bool type_compare(T t1, T t2)

{

    cout << "same" << endl;

    return true;

}


template<typename T, typename U>

bool type_compare(T t1, U t2)

{

    cout << "not same" << endl;

    return false;

}


int main()

{

    auto p1 = 1;

    auto p2 = 1.0;

    cout << type_compare(p1,p2) << endl;


    auto p3 = 1;

    auto p4 = 1;

    cout << type_compare(p3,p4) << endl;



    return 0;

}



사실 이거 비스무리한걸 어디서 봐서, 그걸 응용해서 아랫글을 쓴거다.


이거 처음보고나서 아이쿠마! 라는 생각이 들더라.