J
Jason Heyes
I have a function whose job is to read a non-negative integer. Is this the
right way to do it?
std::istream &read_integer(std::istream &is, int &i)
{
if (!(is >> i) || i < 0)
is.setstate(is.failbit);
return is;
}
Any help is appreciated.
right way to do it?
std::istream &read_integer(std::istream &is, int &i)
{
if (!(is >> i) || i < 0)
is.setstate(is.failbit);
return is;
}
Any help is appreciated.