title: How to add an Initializer List constructor to STL vector
body: <p>So what I want to do is extend the existing vector class in my program to allow me to say this,</p>
  
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;string&gt;* vec = new vector&lt;string&gt;(){"Value1","Value2"};
  </code></pre>
  
  <p>or</p>
  
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;string&gt;* vec = new vector&lt;string&gt;({"Value1","Value2"});
  </code></pre>
  
  <p>or</p>
  
  <pre class="lang-cpp prettyprint-override"><code>vector&lt;string&gt; vec = {"Value1","Value2"};
  </code></pre>
  
  <p>I know I can accomplish something like this but doing this,</p>
  
  <pre class="lang-cpp prettyprint-override"><code>string temp[] = {"Value1","Value2"};
  vector&lt;string&gt; vec(temp, temp+ sizeof(temp) /  sizeof( temp[0] ) ); 
  </code></pre>
  
  <p>This uses the vectors iterator constructor but can't I remove the extra line? </p>
  
  <p>I know in C# you can add whatever you want to existing things by using the <code>partial</code> key word like this,</p>
  
  <pre class="lang-cs prettyprint-override"><code>public partial class ClassName
  {
     ClassName(Stuff stuff)
     {
  
     }
     void AmazingNewMethod()
     {
  
     }    
  }
  </code></pre>
  
  <p>Does C++ have a nifty trick like this somewhere? </p>
  
  <p>Do I have to inherit vector and build a <code>customVector</code> that has a constructor that behind the scenes does the iterator constructor thing?</p>
  
  <p>Maybe wrap those lines in a static Helper Function call that sets it by Reference and add it to a toolbox class somewhere?</p>
  
  <p>I feel like lots of programmers have hit this problem. Are there any elegant solutions out there?</p>
  
  <p>Thanks.</p>
  
  <p>Edit: fixed the title to mention this is an Initializer List constructor.</p>