title: C++ Template const char array to int
body: <p>So, I'm wishing to be able to have a static const compile 
  time struct that holds some value based on a string by using
  templates. I only desire up to four characters. I know that
  the type of 'abcd' is <code>int</code>, and so is 'ab','abc', and although
  'a' is of type <code>char</code>, it works out for a <code>template&lt;int v&gt; struct</code></p>
  
  <p>What I wish to do is take sizes of 2,3,4,5 of some const char, "abcd"
  and have the same functionality as if they used 'abcd'. <em>Note that
  I do not mean 1,2,3, or 4 because I expect the null terminator.</em></p>
  
  <p><code>cout &lt;&lt; typeid("abcd").name() &lt;&lt; endl;</code>  tells me that the type for
  this hard coded string is <code>char const [5]</code>, which includes the null 
  terminator on the end. </p>
  
  <p>I understand that I will need to twiddle the values as characters,
  so they are represented as an integer.</p>
  
  <p>I cannot use <code>constexpr</code> since VS10 does not support it (VS11 doesn't either..)</p>
  
  <p>So, for example with somewhere this template defined, and later the last line</p>
  
  <pre><code>template &lt;int v&gt; struct something {
      static const int value = v;
  };
  
  //Eventually in some method
  cout &lt;&lt; typeid(something&lt;'abcd'&gt;::value).name() &lt;&lt; endl;
  </code></pre>
  
  <p>works just fine.</p>
  
  <p>I've tried</p>
  
  <pre><code>template&lt;char v[5]&gt; struct something2 {
      static const int value = v[0];
  }
  
  template&lt;char const v[5]&gt; struct something2 {
      static const int value = v[0];
  }
  
  template&lt;const char v[5]&gt; struct something2 {
      static const int value = v[0];
  }
  </code></pre>
  
  <p>All of them build individually, though when I throw in my test,</p>
  
  <pre><code>cout &lt;&lt; typeid(something2&lt;"abcd"&gt;::value).name() &lt;&lt; endl;
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>'something2' : invalid expression as a template argument for 'v'
  'something2' : use of class template requires template argument list
  </code></pre>
  
  <hr>
  
  <p>Is this not feasible or am I misunderstanding something? </p>