title: How to design classes with constructor taking a std::initializer_list?
body: <p>When classes have a constructor overload taking a <code>std::initializer_list</code>, this overload will take precedence even if other constructor overloads are seemingly a better match. This problem is described in detail in Sutter's <a href="http://herbsutter.com/2013/05/09/gotw-1-solution/" rel="nofollow">GotW#1</a>, part 2, as well as Meyers' <a href="http://shop.oreilly.com/product/0636920033707.do" rel="nofollow"><em>Effective Modern C++</em></a>, Item 7.</p>
  
  <p>The classic example of where this problem manifests itself is when brace-initializing a <code>std::vector</code>:</p>
  
  <pre><code>std::vector&lt;int&gt; vec{1, 2};
  // Is this a vector with elements {1, 2}, or a vector with a single element 2?
  </code></pre>
  
  <p>Both Sutter and Meyers recommend to avoid class designs where a <code>initializer_list</code> constructor overload can cause ambiguities to the programmer.</p>
  
  <p>Sutter:</p>
  
  <blockquote>
    <p>Guideline: When you design a class, avoid providing a constructor that
    ambiguously overloads with an initializer_list constructor, so that
    users won’t need to use ( ) to reach such a hidden constructor.</p>
  </blockquote>
  
  <p>Meyers:</p>
  
  <blockquote>
    <p>As a result, it’s best to design your constructors so that the
    overload called isn’t affected by whether clients use parentheses or
    braces. In other words, learn from what is now viewed as an error in
    the design of the std::vector interface, and design your classes to
    avoid it.</p>
  </blockquote>
  
  <p>But neither of them describe <em>how</em> <code>vector</code> should have been designed to avoid the problem!</p>
  
  <p>So here's my question: <strong>How should have <code>vector</code> been designed to avoid ambiguities with the <code>initializer_list</code> constructor overload (without losing any features)?</strong></p>