operator! is overloaded for std::ifstream, so you can do this.
In my opinion, though, this is a horrible abuse of operator overloading (by the standards committee). It’s much more explicit what you’re checking if you just do if (stream.fail()).