Boost logo

Boost :

From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-08-23 02:40:27


At Thursday 2002/08/22 10:48, you wrote:
> >From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
>
> > At Thursday 2002/08/22 03:44, you wrote:
> > > >From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
> > >
> > > > At Wednesday 2002/08/21 15:23, you wrote:
> > > > >
> > > > >a discussion on an STLport forum triggered a little discussion on
> > > > >lexical_cast. I believe that current implementation has a couple of
> > >flaws:
> > > > >
> > > > I agree here. I've often thought that
>boost::lexical_cast<std::string>()
> > > > should be a special case that doesn't to the >> afterwards, just swap
>the
> > > > buffer (might as well go for speed while we're at it).
> > >
> > >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;
>
>Well, but is there any point in doing this, then, rather than using the
>stream operators? Either way, it's a copy. If it doesn't copy it, it won't
>work, since the interpreter is transient.

swap is O(1), copy is O(n)

>I thought about this afterwards, so perhaps it wasn't a good idea, after
>all.
>
>
>Regards,
>
>Terje
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
               "There oughta be a law"


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk