mardi 19 novembre 2019

Why did std::basic_ios::operator bool return a void*?

I'm wondering why std::basic_ios::operator void* existed. It's stated that it

Returns a null pointer if fail() returns true, otherwise returns a non-null pointer. This pointer is implicitly convertible to bool and may be used in boolean contexts.

So the result of this implicit conversion was always meant to be used in a boolean expression and the returned pointer does not carry any other information if I'm not mistaken. So the new (since C++11) operator bool is returning the exact same information.

Is there any reason why this implicit conversion to void * existed? Any reason why it was not always operator bool?

Aucun commentaire:

Enregistrer un commentaire