title: How to write the constructor for a template class that wraps a container where the container can be both an array or a vector?
body: <p>I wish to have a general template class that allows the user to pass the container to use:</p>
  
  <pre><code>template&lt;class Container&gt;
  struct Sum
  {
    Container m_terms;
  ...
  </code></pre>
  
  <p>Other classes will derive from that, for example,</p>
  
  <pre><code>class MySum : public Sum&lt;std::vector&lt;int&gt;&gt;
  {
  ...
  </code></pre>
  
  <p>or</p>
  
  <pre><code>class MySum4 : public Sum&lt;std::array&lt;int, 4&gt;&gt;
  {
  ...
  </code></pre>
  
  <p>The containers need to be initialized from the constructor.
  My idea at first was to use <code>std::initializer_list</code>, for example,</p>
  
  <pre><code>MySum ms{1, 2, 3, 4};
  </code></pre>
  
  <p>which would require the following constructors to be added:</p>
  
  <pre><code>template&lt;class Container&gt;
  struct Sum
  {
    Container m_terms;
  
    Sum(std::initializer_list&lt;typename Container::value_type&gt; const&amp; il) :
      m_terms(il) { }
  ...
  </code></pre>
  
  <pre><code>class MySum : public Sum&lt;std::vector&lt;int&gt;&gt;
  {
    using Sum&lt;std::vector&lt;int&gt;&gt;::Sum;
  ...
  </code></pre>
  
  <p>but then how can I get MySum4 to work too? An <code>array</code> doesn't take a <code>std::initializer_list&lt;&gt;</code>.</p>
  
  <p>Here is more complete code that shows the compiler error:
  <a href="https://wandbox.org/permlink/CZW3YaKdInwZZD8e" rel="nofollow noreferrer">https://wandbox.org/permlink/CZW3YaKdInwZZD8e</a></p>