From: Matthias Troyer (troyer_at_[hidden])
Date: 2002-08-22 16:36:28
On Thursday, August 22, 2002, at 12:40 PM, Alberto Barbati wrote:
> Terje Slettebø wrote:
>> Would it really be an advantage to use "t=interpreter.str()" instead
>> of "t
>> << interpreter"? Performance, perhaps. Have you done any measurements,
>> something like that, to show that this specialisation is worthwile?
> It's not just a matter of performances here. "t=interpreter.str()" and
> "interpreter >> t" do two completely different things. In particular,
> the latter stops at the first whitespace while the former does not. In
> fact, one thing that striked me at first when studying lexical_cast is
> that with the current implementation, the expression:
> boost::lexical_cast<std::string>(std::string("hello, world"))
> not only does not return the string "hello, world" but throws an
> exception because of the space. It's very counter-intuitive, IMHO.
I agree with Alberto and also do not like these feature. I have patched
a separate version which returns "hello, world" in this case, since I
this behavior in my applications. Is there any reason for not
lexical_cast for a target of std::string?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk