From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-08-22 12:48:32
>From: "Rob Stewart" <stewart_at_[hidden]>
> From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
> > At Thursday 2002/08/22 03:44, you wrote:
> These attributions are not very helpful. Who's "you?"
> > >That sounds like a good idea. How do you do swap the buffer for
> > >std::stringstream and std::string?
> > you don't, tho I was stunned to see compile and execute (assume using
> > namespace std here):
> > ostringstream ost;
> > ost << 5 << " abcdefghijklmnopqrstuvwxyz";
> > string widget;
> > widget.swap(ost.str());
> > cout << widget << endl;
> > do what I hoped...
> > cout << ost.str() << endl;
> > afterwards still had the original buffer, so I guess str() returns a
> > constructed copy of the buffer;
> The swap is still valuable because it swaps the contents between widget
> temporary returned by ost.str(). The alternative, assigning the temporary
> widget, means that a copy of the temporary's contents is written to widget
> then the temporary is destroyed.
But in what way would this be useful for lexical_cast?
if you have std::string as target, you have something like:
How will a swap help you here?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk