title: Returning large objects from function: by value VS by pointer
body: <p>A function produces large objects. What is the most efficient approach to return those objects from the function?</p>
  
  <ul>
  <li><p>Create an object on the stack and return by value</p></li>
  <li><p>Create an object on the heap, and return it wrapped in a smart pointer</p></li>
  </ul>
  
  <p>I do know that in the first case if the object has a copy constructor the Named Return Value Optimization will be performed. So it should not be a big performance issue. But if there are a lot of those objects produced stack overflow may occur. What option do I choose in which situations?</p>