title: Convert vector<std::string> to vector<double>
body: <p>I have a string vector like <code>{"1.2","3.4","0.5","200.7"}</code>.</p>
  
  <p>I would like to convert each element into double and store it in a <code>vector&lt;double&gt;</code>.</p>
  
  <p>Like so <code>{1.2,3.4,0.5,200.7}</code></p>
  
  <p>What would be the best way to do this?</p>
  
  <p>I know of the <a href="http://www.cplusplus.com/reference/string/stod/" rel="nofollow noreferrer"><code>std::stod(string, size)</code></a>; But I am hoping for a better way to do this.</p>
  
  <p>I was looking for something like: </p>
  
  <pre><code>vector&lt;double&gt; doubleVector = convertStringVectortoDoubleVector(myStringVector);
  </code></pre>
  
  <p>There doesn't seem to be anything like that; so what is the next best thing?</p>
  
  <hr>
  
  <p>EDIT:
  Here's what I ended up using:</p>
  
  <pre><code>std::vector&lt;double&gt; convertStringVectortoDoubleVector(const std::vector&lt;std::string&gt;&amp; stringVector){
  std::vector&lt;double&gt; doubleVector(stringVector.size());
  std::transform(stringVector.begin(), stringVector.end(), doubleVector.begin(), [](const std::string&amp; val)
                   {
                       return stod(val);
                   });
  return doubleVector;}
  </code></pre>
  
  <p>For a complete answer check out zac howland's answer and Chris Jester-Young's answer.
  (P.S. This is based entirely on Zac's answer)
  Thanks</p>