title: no type named ‘type’ in ‘struct std::enable_if<false, void>
body: <p>Why does this not work?</p>
  
  <p>It is giving me an error</p>
  
  <pre><code>error: no type named ‘type’ in ‘struct std::enable_if&lt;false, void&gt;’
       using enable_if_t = typename enable_if&lt;_Cond, _Tp&gt;::type;
  </code></pre>
  
  <p>It I don't put <code>getX()</code> and <code>getY()</code> inside <code>struct B</code> it works. However, if I put them both inside a struct then it doesn't.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;boost/type_traits/has_dereference.hpp&gt;
  
  struct A {
      A(int i) : x(i) {}
      int x;
  };
  
  template&lt;typename T&gt;
  struct B {
      template&lt;typename std::enable_if_t&lt;!boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t.x;
      }
  
      template&lt;typename std::enable_if_t&lt;boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t-&gt;x;
      }
  };
  
  int main()
  {
      A a{4};
  
      B&lt;A&gt; g;
  
      std::cout &lt;&lt; g.getX(a) &lt;&lt; std::endl;
  
      return 0;
  }
  </code></pre>
  
  <p>But, this works fine.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>struct B {
      template&lt;typename T, typename std::enable_if_t&lt;!boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t.x;
      }
  
      template&lt;typename T, typename std::enable_if_t&lt;boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t-&gt;x;
      }
  };
  </code></pre>
  
  <p><strong>Solution</strong></p>
  
  <p>This seems to work:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>template&lt;typename T1&gt;
  struct B {
      template&lt;typename T = T1, typename std::enable_if_t&lt;!boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t.x;
      }
  
      template&lt;typename T = T1, typename std::enable_if_t&lt;boost::has_dereference&lt;T&gt;::value&gt; * = nullptr&gt;
      auto getX(T t) {
          return t-&gt;x;
      }
  };
  </code></pre>