The C++ IO streams\' base class std::basic_ios
defines operator void*()
to return !fail()
and operator!()
to return
Looking at the implementation of MinGW, which is shipped with Codeblocks shows me this code:
operator void*() const
{ return this->fail() ? 0 : const_cast(this); }
bool
operator!() const
{ return this->fail(); }
It seems to me, that the operator void*() const
is intended for more uses than only for the check of success. On top of that it serves also as a casting operator (we're returning this
). Right now I am scratching my head a little bit, why we may want to cast this
to void*
. But the rest is quite clear - if you've got an erroneous stream anyway, you can also return null.