title: Why is this not a constant expression?
body: <p>In this trivial example, <code>test2</code> fails to compile even though <code>test1</code> succeeds, and I don't see why that is the case. If <code>arr[i]</code> is suitable for a return value from a function marked <code>constexpr</code> then why can it not be used as a non-type template argument?</p>
  
  <pre class="lang-c++ prettyprint-override"><code>template&lt;char c&gt;
  struct t
  { 
      static const char value = c;
  };
  
  template &lt;unsigned N&gt;
  constexpr char test1(const char (&amp;arr)[N], unsigned i)
  {
      return arr[i];
  }
  
  template &lt;unsigned N&gt;
  constexpr char test2(const char (&amp;arr)[N], unsigned i)
  {
      return t&lt;arr[i]&gt;::value;
  }
  
  int main()
  {
     char a = test1("Test", 0); //Compiles OK
     char b = test2("Test", 0); //error: non-type template argument 
                                //is not a constant expression
  }
  </code></pre>
  
  <p>Edit: This makes no difference:</p>
  
  <pre class="lang-c++ prettyprint-override"><code>template&lt;char c&gt;
  struct t
  { 
      static const char value = c;
  };
  
  template &lt;unsigned N&gt;
  constexpr char test1(const char (&amp;arr)[N])
  {
      return arr[0];
  }
  
  template &lt;unsigned N&gt;
  constexpr char test2(const char (&amp;arr)[N])
  {
      return t&lt;arr[0]&gt;::value;
  }
  
  int main()
  {
     char a = test1("Test"); //Compiles OK
     char b = test2("Test"); //error: non-type template argument 
                             //is not a constant expression
  }
  </code></pre>