How to check if two template parameters are exactly the same?

c++, c++11, templates

Solution

Using `std::is_same` can provide the desired behaviour:

#include <type_traits>

template<typename T,typename U>
int Foo()
{
    return std::is_same<T, U>::value ? 42 : 0;
}

Problem

How do I modify the following function template so that it returns 42 if template parameters `T` and `U` are exactly the same type? ``` template<typename T,typename U> int Foo() { return 0; } ```

Original source