Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-11-14 11:12:18


troy d. straszheim wrote:

> void load(double & t)
> {
> if(is.fail())
> boost::throw_exception(archive_exception(archive_exception::stream_error));
> char c = is.peek(); while (c == ' ' || c == '\t' || c == '\n') //
> munch leading whitespace { is.get(); c = is.peek(); } if (c == 'n')
> // nan { t = NAN; // you can get one of those with 0.0/0.0,
> robert... if (is.get() != 'n' || is.get() != 'a' || is.get() != 'n')
> boost::throw_exception(archive_exception(archive_exception::stream_error));
> return; if (c == 'i') // positive inf { //etc, etc
>

note that text streams automatically skip white space, so this could be
shortened considerably.

Robert Ramey


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net