title: c++ how to use constexpr value with operator []
body: <p>The origin problem is I want to use <code>const char*</code> or <code>char []</code> in template non-type arguments. Of course it is not supported now. So I want to write some code to convert <code>char[]</code> to <code>std::integer_sequence</code>. But I found a seriously problem.</p>
  <pre><code>#include&lt;utility&gt;
  template&lt;typename T, std::size_t n&gt;
  constexpr auto f3(T (&amp;a)[n])
  {
      return std::integer_sequence&lt;T,a[0]&gt;(); //simplified, it should be &lt;T, a[i],...&gt;
  }
  
  template&lt;typename T, std::size_t n&gt;
  constexpr auto f2(T (&amp;a)[n])
  {
      constexpr T v=a[3];
      //.....other code
      return v;
  }
  
  template&lt;typename T, std::size_t n&gt;
  constexpr auto f1(T (&amp;a)[n])
  {
      return a[3];
  }
  
  int main() 
  {
      constexpr char a[]=&quot;abcdefg&quot;;
      constexpr auto v1=f1(a);
      //constexpr auto v2=f2(a);
      //constexpr auto v3=f3(a);
  }
  </code></pre>
  <p><a href="https://godbolt.org/z/E5YPTM" rel="nofollow noreferrer">https://godbolt.org/z/E5YPTM</a></p>
  <p>The f1 is ok but f2 &amp; f3 are wrong. I confused..... Why is that?
  It looks like that only &quot;return xxx[yyy]&quot; is ok for compile-time. I can not store it in value or passing it to other functions.</p>