[ create a new paste ] login | about

Link: http://codepad.org/7c5f5HvP    [ raw code | output | fork ]

GManNickG - C++, pasted on Apr 19:
#include <iostream>

// in the general case, T and U are different
template <typename T, typename U>
struct is_same
{
    static const bool value = false;
};

// but in this specialization, they are the same
template <typename T>
struct is_same<T, T>
{
    static const bool value = true;
};

template <typename T, typename U>
bool check(void)
{
    return is_same<T, U>::value;
}

int main(void)
{
    std::cout << std::boolalpha;

    std::cout << check<int, float>() << ' ';
    std::cout << check<int, int>() << std::endl;
}


Output:
1
false true


Create a new paste based on this one


Comments: