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 <bool, typename>
struct enable_if {
};
template <typename T>
struct enable_if<true, T> {
    typedef T type;
};

template <typename OutType, typename InType>
typename enable_if<is_same<OutType, InType>::value, OutType>::type foo(const InType& x)
{
    // OutType == InType
    return x;
}
template <typename OutType, typename InType>
typename enable_if<!is_same<OutType, InType>::value, OutType>::type foo(const InType& x)
{
    // OutType != InType
    return x + x;
}

#include <iostream>
int main()
{
    std::cout << foo<int>(1) << '\n'
              << foo<long>(1) << '\n';
}
