std::conditional vs std::enable_if : <p>I have a hashing function that can take any object type and hash it, it uses <code>std::hash</code> internally. Because <code>std::hash</code> does not support enum types I've created overloads of the function, 1 for enumerations using <code>std::underlying_type</code> and 1 for other types:</p>

<pre><code>template &lt;typename T, typename std::enable_if&lt;std::is_enum&lt;T&gt;::value&gt;::type* = nullptr&gt;
static std::size_t Hash(T const &amp; t)
{
    return std::hash&lt;typename std::underlying_type&lt;T&gt;::type&gt;()(t);
}

template &lt;typename T, typename std::enable_if&lt;!std::is_enum&lt;T&gt;::value&gt;::type* = nullptr&gt;
static std::size_t Hash(T const &amp; t)
{
    return std::hash&lt;T&gt;()(t);
}
</code></pre>

<p>This is working fine.
I then tried to put it all into a single function with <code>std::conditional</code>:</p>

<pre><code>template &lt;typename T&gt;
static std::size_t Hash(T const &amp; t)
{
    typedef typename std::conditional&lt;std::is_enum&lt;T&gt;::value, std::hash&lt;typename std::underlying_type&lt;T&gt;::type&gt;, std::hash&lt;T&gt;&gt;::type Hasher;
    return Hasher()(t);
}
</code></pre>

<p>Main:</p>

<pre><code>enum test
{
    TEST = 2
};

int main() {
    Hash&lt;test&gt;(TEST);
    Hash&lt;int&gt;(5);
    std::cin.get();
    return 0;
}
</code></pre>

<p>This however, gave me an <a href="http://ideone.com/CKckZD" rel="noreferrer">error</a> :</p>

<blockquote>
  <p>/usr/include/c++/5/type_traits:2190:38: error: 'int' is not an enumeration type
         typedef __underlying_type(_Tp) type;</p>
</blockquote>

<p>I do understand the error but I don't understand why, I thought <code>std::conditional</code> would prevent these compile-time errors because <code>&lt;int&gt;</code> uses <code>std::hash&lt;T&gt;</code> instead of  <code>std::hash&lt;typename std::underlying_type&lt;T&gt;::type&gt;</code> at compile-time.</p>

<p>What am I doing wrong here, is there a way I can merge the 2 functions?</p>
