Template syntax for C++

75 Views Asked by At

I have encountered a template syntax that I am not able to understand :

template <typename T, typename U>
struct is_same
{
    static const bool value = false;
};

template <typename T>
struct is_same<T, T>
{
    static const bool value = true;
};

template <class A, class B>
bool IsSameClass() {
    return is_same<A, B>::value;
}

The above program implement a template boolean function IsSameClass() that return true if both the classes are of same type.

I don't understand this part :

template <typename T>
struct is_same<T, T>
{
    static const bool value = true;
};

Is it structure taking two argument ?

0

There are 0 best solutions below