title: Should small simple structs be passed by const reference?
body: <p>I have always been taught that non-primitive types should be passed by const reference rather than by value where possible, ie:</p>
  
  <pre><code>void foo(std::string str);//bad
  void foo(const std::string &amp;str);//good
  </code></pre>
  
  <p>But I was thinking today that maybe actually some simple user defined types may actually be better passed by value eg:</p>
  
  <pre><code>class Vector2
  {
  public:
      float x, y;
      ...constructors, operators overloads, utility methods, etc...
  };
  
  void foo(Vector2 pos);
  void foo(const Vector2 &amp;pos);//is this really better than by value?
  void foo(float x, float y);//after all isn't by value effectively doing this?
  </code></pre>
  
  <p>My thought is that by passing the Vector2 by reference, it is actually more expensive than passing by value since the compiler is now using a pointer and dereferencing to access the const Vector2 &amp;pos version?</p>
  
  <p>Is this the case? Are simple objects best off passed by value? Where should the line be drawn?</p>