fork download
  1.  
  2. sorted(std::vector<std::string> names)
  3. {
  4. std::sort(names);
  5. return names;
  6. }
  7.  
  8.  
  9. std::vector<std::string>
  10. sorted2(std::vector<std::string> const& names) // names passed by reference
  11. {
  12. std::vector<std::string> r(names); // and explicitly copied
  13. std::sort(r);
  14. return r;
  15. }
  16.  
  17.  
  18. /*
  19. ...
  20. Even if the actual argument to sorted2 is an rvalue, the source of the copy, names, is an lvalue,3 so the copy can’t be optimized away.
  21. ...
  22.  
  23. How is names in sorted2 an lvalue? But supposedly in sorted it isn't? What?
  24.  
  25. Source: http://c...content-available-to-author-only...t.com/archive/2009/08/want-speed-pass-by-value
  26. Implications paragraph.
  27.  
  28.  
  29. */
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty