title: What is wrong with my application of SFINAE when trying to implement a type trait?
body: <p>I needed a type trait that decays enums to their underlying type, and works the same as <code>decay_t</code> for all other types. I've written the following code, and apparently this is not how SFINAE works. But it is how I thought it should work, so what exactly is the problem with this code and what's the gap in my understanding of C++?</p>
  <pre><code>namespace detail {
      template &lt;typename T, std::enable_if_t&lt;!std::is_enum_v&lt;T&gt;&gt;* = nullptr&gt;
      struct BaseType {
          using Type = std::decay_t&lt;T&gt;;
      };
  
      template &lt;typename T, std::enable_if_t&lt;std::is_enum_v&lt;T&gt;&gt;* = nullptr&gt;
      struct BaseType {
          using Type = std::underlying_type_t&lt;T&gt;;
      };
  }
  
  template &lt;class T&gt;
  using base_type_t = typename detail::BaseType&lt;T&gt;::Type;
  </code></pre>
  <p>The error in MSVC is completely unintelligible:</p>
  <blockquote>
  <p>'detail::BaseType': template parameter '__formal' is incompatible with
  the declaration</p>
  </blockquote>
  <p>In GCC it's a bit better - says that declarations of the second template parameter are incompatible between the two <code>BaseType</code> templates. But according to my understanding of SFINAE, only one should be visible at all for any given T and the other one should be malformed thanks to <code>enable_if</code>.</p>
  <p><a href="https://godbolt.org/z/49v3xd7Mr" rel="noreferrer">Godbolt link</a></p>