title: if constexpr and requires-expression for ad-hoc concepts checking
body: <p>Let's say, given C++17's <code>if constexpr</code> and Concepts TS (for instance, in recent gcc versions), we'd like to check if a type in a template function has a nested type:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  
  struct Foo { using Bar = int; };
  
  template&lt;typename T&gt;
  void doSmth(T)
  {
      if constexpr (requires { typename T::Bar; })
          std::cout &lt;&lt; "has nested! " &lt;&lt; typename T::Bar {} &lt;&lt; std::endl;
      else
          std::cout &lt;&lt; "no nested!" &lt;&lt; std::endl;
  }
  
  int main()
  {
      doSmth(Foo {});
      //doSmth(0);
  }
  </code></pre>
  
  <p>The documentation for concepts is scarce, so I might have got it wrong, but seems like that's it (and the live example is on <a href="https://wandbox.org/permlink/QIBdPOsxSVK5AD9r" rel="noreferrer">Wandbox</a>).</p>
  
  <p>Now let's consider what should happen when uncommenting the other <code>doSmth</code> call. It seems reasonable to expect that the requires-clause would evaluate to <code>false</code>, and the <code>else</code> branch of the <code>if constexpr</code> will be taken. Contrary to that, gcc makes this a hard error:</p>
  
  <pre><code>prog.cc: In instantiation of 'void doSmth(T) [with T = int]':
  prog.cc:17:13:   required from here
  prog.cc:8:5: error: 'int' is not a class, struct, or union type
       if constexpr (requires { typename T::Bar; })
       ^~
  </code></pre>
  
  <p>Is that a bug in gcc, or is that the intended behaviour?</p>