id summary reporter owner description type status milestone component version severity resolution keywords cc 2659 optional_io insertion operator assumes presence of whitespace on stream Andrew Troschinetz Fernando Cacciola "In optional_io.hpp, the insertion operator is written as: {{{ if ( in.good() ) { int d = in.get(); if ( d == ' ' ) { T x ; in >> x; v = x ; } else v = optional() ; } }}} However the assumption that there must be a space on the stream means something like this fails: {{{ istringstream in (""test""); optional s; assert (s); }}} It fails because we eat 'd', throw it away, and then return an empty optional object because we didn't get the space we were expecting. If the intent was to eat up spare whitespace, I would prepose something like this: {{{ if (in) { T x; if (in >> std::ws >> x) v = x; else v = optional(); } return in; }}} However doesn't that interfere with the intent of the skipws flag? For example: {{{ istringstream in ("" test1 test2""); optional s; in >> s; assert (s); in.unsetf (ios::skipws); in >> s; assert (!s); }}} This doesn't work with ""in >> std::skipws >> x"" because the second assertion will fail. Instead you'd need to use ""in >> x"", which I believe would is the best solution." Bugs closed Boost 1.38.0 optional Boost 1.37.0 Problem wontfix