This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Switch question
I wrote:
| > Actually, even though the definitions are permitted, the overloads are
| > not.
I was wrong. 17.3.2.1.2/1 says
Several types defined in clause 27 are bitmask types. Each bitmask
type can be implemented as an enumerated type that overloads
certain operators, as an integer type, or as a bitset (23.3.5).
Ryszard Kabatek <Ryszard.Kabatek@softax.pl> wrote:
| I hope it will be fixed in the gcc-3.0 release.
Actually, as it turns out that isn't a compiler bug nor a library bug.
It is a quality of implementation issue.
| In other case one will have to write something like that:
|
| #include <iostream>
|
| int f(std::ios_base::openmode mode)
| {
| switch(mode & ~std::ios_base::ate) {
| case static_cast<int>(std::ios_base::out) |
| static_cast<int>(std::ios_base::trunc):
This is not portable either.
I think you're left with a sequence of if/else if.
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com