Is there any way to get a specific error condition when a C++ stream open fails? That is, whether it failed because the file didn't exist, or permissions were wrong, or etc. Basically I'm looking for functionality equivalent to errno for fopen() in plain C.
GCC seems to set errno properly, but that doesn't seem to be required by the C++ standard and I can't determine whether this is just an artifact of the way they implemented streams, or a deliberate feature (and thus I don't know whether it will persist across versions).
Is there a way to get this info reliably, either in standard C++ or non-accidentally in one or more major compilers?