title: Implementing a std::array-like container with a C++11 initializer_list
body: <p>The only and imo very inconvenient caveat of <code>std::array</code> is that it can't deduce its size from the initializer list like built-in C arrays, it's size must be passed as a template.</p>
  
  <p>Is it possible to implement a std::array-like container (a thin wrapper around a built-in C array) with a <code>C++11</code> initializer_list?</p>
  
  <p>I ask because, unlike std::array, it would automatically deduce the size of the array from the initializer list which is a lot more convenient. For example:</p>
  
  <pre><code>// il_array is the hypothetical container
  // automatically deduces its size from the initalizer list 
  il_array &lt;int&gt; myarr = {2, 4, 6, 7, 8}; 
  </code></pre>
  
  <p>We would also want to provide a constructor to specify the size if an initializer list was not provided. For example:</p>
  
  <pre><code>// construct a fixed size array of size 10
  il_array &lt;int&gt; myarr2 (10); 
  </code></pre>
  
  <p>This would also make the container more consistent with the other standard containers e.g. vector, deque and list.</p>
  
  <p>To the best of my knowledge it isn't possible as the wrapped C-array e.g. T elems [size], must have constant size and initializer_list's size() member function isn't constant.</p>
  
  <p>Also, I was wondering if was possible to implement such a container using a variadic template although from what I've read I don't think it's possible.</p>