title: Why can't I initialize vector<foo> from std::initializer_list<string> if foo has a non-explicit constructor from string?
body: <p>Using C++11 in MS Visual Studio 2013, I have a class testNetInfo that has a non-explicit constructor from std::string, and I would like to construct a vector of these from a std::initializer list of strings.</p>
  
  <p>If I construct a temporary vector from the initializer_list, I can use that to set up the real vector:</p>
  
  <pre><code>void SimComparisonTests::compareCombinationalGateWithXorZ(const std::string&amp; outNetName, std::initializer_list&lt;std::string&gt; initList) {
  
  std::vector&lt;std::string&gt; inNetNames(initList);
  std::vector&lt;testNetInfo&gt; netInfo;
  for (auto nn = inNetNames.begin(); nn != inNetNames.end(); ++nn) {
      netInfo.push_back(testNetInfo(*nn));
  }
  </code></pre>
  
  <p>But trying to create netInfo directly from initList like this:</p>
  
  <p><code>std::vector&lt;testNetInfo&gt; netInfo(initList);</code> </p>
  
  <p>gives the following error:</p>
  
  <ul>
  <li>error C2664: 'std::vector>::vector(std::initializer_list,const std::allocator&lt;_Ty> &amp;)' : cannot convert argument 1 from 'std::initializer_list,std::allocator>>' to 'const std::allocator&lt;_Ty> &amp;'          with
  2>          [
  2>              _Ty=testNetInfo
  2>          ]
  2>          Reason: cannot convert from 'std::initializer_list,std::allocator>>' to 'const std::allocator&lt;_Ty>'
  2>          with
  2>          [
  2>              _Ty=testNetInfo
  2>          ]
  2>          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called</li>
  </ul>
  
  <p>It looks like I can avoid this error if I change the type of initList to <code>initializer_list&lt;testNetInfo&gt;</code>, and add a constructor from const char *, so that I can pick up a call like: </p>
  
  <pre><code>compareCombinationalGateWithXorZ("triOut3", {"triIn3", "triEn3"});
  </code></pre>
  
  <p>But a possible catch with that fix is that the conversion from string (or const char *) to a testNetInfo object has to be done after run-time assignment of a class static pointer in testNetInfo that is used to do the name lookup to initialize the rest of the object.  This will be done by the time the above function is called, and the above initialization looks ok in my implementation, but would I be pushing undefined behavior by declaring an <code>initializer_list&lt;testNetInfo&gt;</code> with a class that has a run-time prerequisite like this (i.e., is it possible that an implementation might try to build the initializer_list before the caller is executed)?  If so, is there a cleaner way to do this?</p>