title: Use of constexpr function before definition fails
body: <p>I'm having some trouble with <code>constexpr</code>. The book <em>C++ Primer</em> shows a line of code:</p>
  
  <pre><code>  constexpr int sz = size(); // only size() is a constexpr function
                               // this code is right
  </code></pre>
  
  <p>However the book doesn't give a specific example. So I try the following code by myself:</p>
  
  <pre><code>#include &lt;iostream&gt;
  constexpr int fun();
  int main()
  {
      constexpr int f = fun();
      std::cout &lt;&lt; f &lt;&lt; std::endl;
  }
  constexpr int fun()
  {
      return 3;
  }
  </code></pre>
  
  <p>But my compiler said <code>fun()</code> is undefined.</p>
  
  <p>If I change <code>constexpr</code> into <code>const</code>, it works well, and if I change my code to define the constexpr function before use:</p>
  
  <pre><code>#include &lt;iostream&gt;
  constexpr int fun()
  {
      return 3;
  }
  int main()
  {
      constexpr int f = fun();
      std::cout &lt;&lt; f &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>It also works well. Can someone tell me why?</p>