title: Which is more efficient: Return a value vs. Pass by reference?
body: <p>I am currently studying how to write efficient C++ code, and on the matter of function calls, a question comes to mind. Comparing this pseudocode function:</p>
  
  <pre><code>not-void function-name () {
      do-something
      return value;
  }
  int main () {
      ...
      arg = function-name();
      ...
  }
  </code></pre>
  
  <p>with this otherwise-identical pseudocode function:</p>
  
  <pre><code>void function-name (not-void&amp; arg) {
      do-something
      arg = value;
  }
  int main () {
      ...
      function-name(arg);
      ...
  }
  </code></pre>
  
  <p>Which version is more efficient, and in what respect (time, memory etc.)? If it depends, then when would the first be more efficient and when would the more efficient be the second?</p>
  
  <p><strong>Edit</strong>: For context, this question is limited to hardware platform-independent differences, and for the most part software too. Are there any machine-independent performance difference?</p>
  
  <p><strong>Edit</strong>: I don't see how this is a duplicate. The other question is comparing passing by reference (prev. code) to passing by value (below):</p>
  
  <pre><code>not-void function-name (not-void arg)
  </code></pre>
  
  <p>Which is not the same thing as my question. My focus is not on which is the better way to pass in an argument to a function. My focus is on which is the better way to pass <strong>out</strong> a result to a variable from the outside scope.</p>