I had a typo (||
instead of |
) and noticed such a code fails with GCC and compiles with Visual.
I know that the second parameter of std::ifstream
is an int
. So theoretically, a bool
has to be converted implicitely to an int
. So why it fails?
Example inducing the error (I just used some ints instead of the flags).
#include <fstream>
int main(int argc, char * argv[]) {
std::ifstream("foo", 2 | 3 || 4)
}
std::ifstream
's constructor takes as second argument an std::ios_base::openmode
which is typedef
ed from an implementation defined type:
typedef /*implementation defined*/ openmode;
It seems Visual uses integers, GCC does not, and it's why your code fails on GCC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With