|
Boost : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-04-21 04:07:50
As already noted, new lexical_cast disables whitespace skipping, which breaks
cases like
lexical_cast<int>(" 1");
I've just found a more serious consequence:
class Estimation_context {
public:
Estimation_context() {}
private:
int resource_count;
int eta_ir1;
int bline1;
friend std::istream& operator>>(std::istream&, Estimation_context&);
};
istream& operator>>(istream& is, Estimation_context& c)
{
is >> c.resource_count >> c.eta_ir1 >> c.bline1;
return is;
}
More complex version of this code used to work, but now
lexical_cast<Estimation_context>("50 0 1 ");
throws exception, because embedded spaces are not skipped. If I write
is >> c.resource_count >> ws >> c.eta_ir1 >> ws >> c.bline1;
everything works, but is this a good solution? I think not skipping whitespace
in operator>> is idiomatic usage and I would not like adding those "ws" to
all operators>> just for lexical_cast sake.
- Volodya
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk