10 minutes ago, alvaro said:It's not just allowed: It's completely idiomatic. Take for instance std::ios_base::openmode . I just looked at its implementation in gcc 7.1.0 and it's an enum, where a few constants have been defined as powers of 2 and you then use them like this:
std::ofstream ofs; ofs.open ("test.txt", std::ofstream::out | std::ofstream::app);
If you are not familiar with this idiom, you just don't know C++.
[EDIT: By the way, in gcc 7.1.0 <bits/ios_base.h> defines the operators &, |, ^, ~, |=, &= and ^= for this type.]
According to cppreference, the exact type of std::ios_base::openmode is implementation defined.
http://en.cppreference.com/w/cpp/io/ios_base/openmode
Again, though, just because one particular implementation of the standard library does it, doesn't mean it's actually a good idea.