A colleague just told me that this code:
std::ifstream stream(filename.c_str());
if (!stream)
{
throw std::runtime_error(\"..\");
}
wou
You can also use is_open() to check if it worked, but ! is allowed (it's not checking for zero, it's a special overload of ! )
edit:
Just out of interest - why doesn't this throw an exception?
Is it just that streams were introduced before exceptions
or are we into the old C++ thing of - it's only an error not exceptional enough to be an exception.