title: if constexpr(condition) as compile-time conditional
body: <p>I want to use a constexpr bool (<code>useF</code> in the example below) to enable a feature in the following code. Here, calling <code>A::f()</code>. Additionally, I want to be the alias-template (<code>a</code>) to be <code>void</code> in the case I switch off the feature.</p>
  
  <p>I tried to use a constexpr if statement, but the body is still being instantiated, which causes a compile error. If I use a wrapper template (<code>X</code>), the body is being discarded as I'd expected, but that seems ugly to me. Are there any other ways to do this?</p>
  
  <pre><code>constexpr bool useF = false;
  
  struct A {
      static void f() {}
  };
  
  using a = std::conditional&lt;useF, A, void&gt;::type;
  
  template&lt;typename L&gt;
  struct X {
      static void h() {
          if constexpr(std::is_same&lt;L, A&gt;::value) {
              L::f(); // not instantiated, no error
          }
      }
  };
  
  int main() {
      if constexpr(useF) {
          a::f(); // error!?
      }
  
      X&lt;a&gt;::h();
  }
  </code></pre>
  
  <p>I am using g++-7.0.1 with -std=c++17</p>