title: How can my code do one thing at compile-time, but another thing at run-time?
body: <p>I'm implementing a <code>constexpr int foo();</code> function. In the body of <code>foo()</code>, I want to do something different (and possibly return something different) at compile time and something different at run-time.</p>
  <p>With C++20, I can use <a href="https://en.cppreference.com/w/cpp/types/is_constant_evaluated" rel="nofollow noreferrer"><code>std::is_constant_evaluated</code></a>:</p>
  <pre><code>constexpr int foo() { return std::is_constant_evaluated() ? 123 : 456 };
  </code></pre>
  <p>but what if I'm using C++17 (or earlier) - what can I do with the same effect?</p>
  <p>Note: Compiler-specific solutions are acceptable (though less desirable).</p>