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*

20
  • 1
    Are you sure that is copying? Its a perfectly reasonable case for applying RVO I think. Inspect your assembly to see what your compiler is doing. Commented Oct 8, 2014 at 21:19
  • 2
    @Manu343726 RVO applies to a return value. There is no return here. Commented Oct 8, 2014 at 21:22
  • 6
    Standard says about str(): "returns a string object with a copy of the current contents of the stream." So yes it copies Commented Oct 8, 2014 at 21:23
  • 1
    As QoI, an implementation could do something nice with move(ss).str(), but I don't know if any does right now. Commented Oct 8, 2014 at 21:26
  • 1
    @galinette Yes, you can, though I think most compilers don't support that well. Commented Oct 8, 2014 at 21:31