title: How can I force a compilation error in a constexpr function, instead of letting it decay into a non-constexpr context?
body: <p>Here's the code I would like to be able to write:</p>
  
  <pre><code>int id1 = not_const_expr_1();
  int id10 = not_const_expr_10();
  
  constexpr Device&amp; cD1 = get_device(1);    // 1. ok
  constexpr Device&amp; cD10 = get_device(10);  // 2. compile error
  
  Device&amp; cD1 = get_device(1);    // 3. ok
  Device&amp; cD10 = get_device(10);  // 4. compile error
  
  Device&amp; D1 = get_device(id1);    // 5. ok
  Device&amp; D10 = get_device(id10);  // 6. exception, log message, infinite loop, or something
  </code></pre>
  
  <p>Here's what I tried:</p>
  
  <pre><code>template&lt;typename T&gt;
  T failed(const char*) { while(1); }  // could also throw exception
  
  constexpr Device&amp; dev1 = ...;
  constexpr Device&amp; dev42 = ...;
  
  constexpr Device&amp; get_device(uint8_t which) {
      return which == 1 ? dev1 :
             which == 42 ? dev42 :
             // more here, but not important
             failed&lt;Device&amp;&gt;("Device does not exist");
             // string argument just to aid with compiler error message
  }
  </code></pre>
  
  <p>This passes all the above testcases except number 4. Unfortunately, the error is not caught at compile-time, as the compiler finds that for the given argument, <code>get_device</code> is not <code>const_expr</code>.</p>
  
  <p>Is there any way I can work a <code>static_assert</code> in here, without breaking things in the non-constexpr context?</p>