title: How to add element by element of two STL vectors?
body: <p>The question is quite dumb, but I need to do it in a very efficient way - it will be performed over an over again in my code. I have a function that returns a vector, and I have to add the returned values to another vector, element by element. Quite simple:</p>
  
  <pre><code>vector&lt;double&gt; result;
  vector&lt;double&gt; result_temp
  for(int i=0; i&lt; 10; i++) result_temp.push_back(i);
  
  result += result_temp //I would like to do something like that.
  for(int i =0; i&lt; result_temp.size();i++)result[i] += result_temp[i]; //this give me segfault
  </code></pre>
  
  <p>The mathematical operation that I'm trying to do is</p>
  
  <p>u[i] = u[i] + v[i] for all i</p>
  
  <p>What can be done?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: added a simple initialization, as that is not the point. How should result be initialized?</p>