Subject: Re: [Boost-bugs] [Boost C++ Libraries] #2659: optional_io insertion operator assumes presence of whitespace on stream
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-02-05 16:10:02
#2659: optional_io insertion operator assumes presence of whitespace on stream
--------------------------------------------------------+-------------------
Reporter: Andrew Troschinetz <ast_at_[hidden]> | Owner: fcacciola
Type: Bugs | Status: new
Milestone: Boost 1.38.0 | Component: optional
Version: Boost 1.37.0 | Severity: Problem
Resolution: | Keywords:
--------------------------------------------------------+-------------------
Comment(by Andrew Troschinetz <ast_at_[hidden]>):
And once again, even better:
{{{
if (in)
{
T x;
if (in >> x)
{
v = x;
}
else
{
if (in.fail () && !in.eof ())
{
in.clear ();
in.get ();
}
v = optional<T> ();
}
}
else
{
v = optional<T> ();
}
return in;
}}}
Instead of reading in a std::string, we should really just skip over the 1
character that gave us trouble and keep trying. Also added a check to make
sure we didn't fail b/c we tried to read past eof, because if that's the
case we really should fail and not try to recover.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2659#comment:4> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC