From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-08-09 06:38:14
Thomas Matelich wrote:
> You'll note that stream >> std::ws is no longer called.
> One note that I must make is that I do not have the vanilla source for
> lexical_cast. From the last time lexical_cast broke my source, I've
> commented out stream.unsetf(std::ios::skipws); in the lexical_stream
> constructor (see
> http://lists.boost.org/MailArchives/boost-users/msg03656.php for the
> I just recalled a unit test we have that would expose the problem (and
> it did). By adding a [stream >> std::ws &&] before the check for eof,
> my problem was resolved. Is there a reason we want to fail with
> trailing whitespace?
I'm not the lexical_cast author, but I do know there were discussions
about this in the Boost mailing lists (search the archives, one of these
threads was started by me). The reason for changing it was symmetry. In
Boost 1.32, trailing whitespaces were ignored, while leading whitespaces
were not. This is clearly wrong because there's no reason for asymmetry
here. So the decision (which I'm fully agree with, BTW) is to *not*
ignore whitespaces at all.
If you want to ignore whitespaces, then the (simple) suggestion I can
give you is to trim (the string_algo Boost library) the string before
sending it to lexical_cast.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk