Re: Iterating through an enum???
From: Simon Trew (noneofyour_at_business.guv)
Date: 04/26/04
- Next message: Scott McPhillips [MVP]: "Re: Structure sizes"
- Previous message: Tony: "Re: error C2678, string "+""
- In reply to: muchan: "Re: Iterating through an enum???"
- Next in thread: muchan: "Re: Iterating through an enum???"
- Reply: muchan: "Re: Iterating through an enum???"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 26 Apr 2004 17:31:44 +0100
"muchan" <usenet@usenet.usenet> wrote in message
news:Jzajc.1608$37.234736@news.siol.net...
> >
> > The names of the enums don't exist at runtime, and no checking is done
that
> > the value is one of the defined values. So you can just use the enum as
a
> > number. The above example, using enums as a set of flags, is quite
common.
> >
>
> Interesting. And in this case, what ++ operator should do with enum? 8)
I think that is rather the point. Schobi defined a ++ operator which skipped
through the *defined* values of the enum. I did the same, only in a more
generic manner using a set to hold the values. (It would be better as a
template class and I have in fact templatized a version but I doubt it is
worth posting here.) A specialized iterator onto an underlying vector would
probably be a better choice; I coded up a set implementation as it avoided
the use of an iterator (in the style of STL iterators, anyway) so the
control variable could be of the enum type itself.
S.
- Next message: Scott McPhillips [MVP]: "Re: Structure sizes"
- Previous message: Tony: "Re: error C2678, string "+""
- In reply to: muchan: "Re: Iterating through an enum???"
- Next in thread: muchan: "Re: Iterating through an enum???"
- Reply: muchan: "Re: Iterating through an enum???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|