title: constexpr exp, log, pow
body: <p>I'd like to use <code>constexpr</code> versions of standard <code>&lt;cmath&gt;</code> functions like <code>exp</code>, <code>log</code>, <code>pow</code> in a portable way. I currently have a non-portable solution <a href="https://stackoverflow.com/questions/22182432/is-gcc-considering-builtins-of-non-constant-expression-functions-to-be-constant"><code>g++</code> treats these functions as <code>constexpr</code> - a non-compliant extension of C++</a>, but I am concerned about portability and future-proofing (I imagine that this extension might one day be removed from <code>g++</code>).</p>
  
  <p>I am interested in <code>constexpr</code> versions of these functions, not template metaprograms - I want the same functionality to be available both at compile time and runtime. I do not need C compatibility, but I do need fast implementations - naive implementations such as Taylor Series expansions would be too slow.</p>
  
  <p><strong>How can I implement such functionalities?</strong> I am specifically interested in <code>exp</code>, <code>log</code>, and <code>pow</code></p>
  
  <p><strong>Some tangentially related things I've learned from my research</strong></p>
  
  <ul>
  <li>The standard-compliant versions of these functions aren't technically <code>constexpr</code> because they must have side-effects (e.g. setting <code>errno</code>) to maintain C compatibility</li>
  <li>In C++11, an implementation was allowed to make these functions <code>constexpr</code>, but as of C++14, this is prohibited (per <a href="https://stackoverflow.com/questions/27744079/is-it-a-conforming-compiler-extension-to-treat-non-constexpr-standard-library-fu">the first answer to this question</a> and <a href="https://software.intel.com/en-us/forums/intel-c-compiler/topic/484936" rel="noreferrer">the answer to this question</a>). This is part of the reason that I am concerned that the functions may not be <code>constexpr</code> in future versions of <code>g++</code></li>
  <li><code>g++</code>'s implementation of each math function <code>foo</code> just calls a built-in function <code>__builtin_foo</code>, which is treated as <code>constexpr</code>. I could perhaps start calling the <code>__builtin_foo</code> functions rather than the <code>foo</code> functions - these might remain <code>constexpr</code> in future versions of <code>g++</code> even if the corresponding <code>foo</code> functions are made compliant - but this only helps with future-proofing, not with portability.</li>
  </ul>