Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 1
    std::string is a standard library class. It already is both moveable and copyable. I don't see how this is relevant. The OP is asking more about the performance of move vs. references, not the performance of move vs. copy. Commented Apr 19, 2012 at 16:19
  • 3
    This answer counts the number of moves and copies a std::string will undergo under the pass-by-value design described by both Herb and Dave, vs passing by reference with a pair of overloaded functions. I use the OP's code in the demo, except for substituting in a dummy string to shout-out when it is getting copied/moved. Commented Apr 19, 2012 at 16:35
  • You should probably optimize the code before performing the tests… Commented Dec 8, 2014 at 11:42
  • 3
    @TheParamagneticCroissant: Did you get different results? If so, using what compiler with what command line arguments? Commented Dec 8, 2014 at 15:18