title: Performance cost of passing by value vs. by reference or by pointer?
body: <p>Let's consider an object <code>foo</code> (which may be an <code>int</code>, a <code>double</code>, a custom <code>struct</code>, a <code>class</code>, whatever). My understanding is that passing <code>foo</code> by reference to a function (or just passing a pointer to <code>foo</code>) leads to higher performance since we avoid making a local copy (which could be expensive if <code>foo</code> is large).</p>
  
  <p>However, from the answer <a href="https://stackoverflow.com/questions/399003/is-the-sizeofsome-pointer-always-equal-to-four">here</a> it seems that pointers on a 64-bit system can be expected in practice to have a size of 8 bytes, regardless of what's being pointed. On my system, a <code>float</code> is 4 bytes. Does that mean that if <code>foo</code> is of type <code>float</code>, then it is <strong>more efficient</strong> to just pass <code>foo</code> by value rather than give a pointer to it (assuming no other constraints that would make using one more efficient than the other inside the function)?</p>