Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2002-08-22 14:00:32

X-BeenThere: boost_at_[hidden]
X-Mailman-Version: 2.1b1
Precedence: bulk
Reply-To: boost_at_[hidden]
List-Help: <mailto:boost-request_at_[hidden]?subject=help>
List-Post: <mailto:boost_at_[hidden]>
List-Subscribe: <>,
List-Id: Boost mailing list <>
List-Unsubscribe: <>,
X-List-Received-Date: Thu, 22 Aug 2002 19:00:03 -0000

From: =?Windows-1252?Q?Terje_Sletteb=F8?= <tslettebo_at_[hidden]>
> >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?"
> Me. :)

Unfortunately, his attribution line doesn't make that clear.

> > The swap is still valuable because it swaps the contents between widget
> and the
> > temporary returned by ost.str(). The alternative, assigning the temporary
> to
> > widget, means that a copy of the temporary's contents is written to widget
> and
> > then the temporary is destroyed.
> But in what way would this be useful for lexical_cast?

That may well be a separate question from the one I was answering!

> if you have std::string as target, you have something like:
> std::stringstream interpreter;
> ...
> return std::string(interpreter.c_str());
> How will a swap help you here?

My guess is that you meant:

    return std::string(interpreter.str());

In that case, swap() is not useful, since this line makes explicit the copy
construction that must -- in theory -- occur anyway. (Actually, I'm left to
wonder whether this tells the compiler to invoke the copy constructor, thus
preventing the RVO.) There is no place for a swap to occur as there is no named
return value to swap with and str() already creates a copy of the
stringstream's internal buffer.

Rob Stewart                           stewart_at_[hidden]
Software Engineer           
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at, gregod at, cpdaniel at, john at