Boost logo

Boost :

From: Kevlin Henney (Kevlin.Henney_at_[hidden])
Date: 1999-12-10 05:21:51

Paul Tozour wrote:
> Forgive me if this issue has come up before; I'm new to the Boost
> group.
> A lot of my work deals with enumerated types. Unfortunately, enumerated
> types are very much a dark back corner of the language at the moment.
> Although they are hugely useful for a number of tasks, they lack a number
> the basic features one would expect from such a language feature.
> For example, there is no way (unless I'm missing something obvious) to
> iterate over an enumerated type (at least, there is no built-in language
> support for this). One would think that since it's called an
> type, you could at least enumerate its elements, but you can't. You also
> cannot find the first or last element of an enumerated type, query
> membership, etc. Being able to query the validity of an enumerated type
> especially important as one often saves enumerated types to data files,
> it's impossible to validate the data when you read it in again unless you
> have some way of ensuring that the enumerated type value you're reading
> is really a part of that type.
> What does everyone think of this? Is anyone aware of a reasonable,
> solution to this problem?
> If not, given that this could be implemented without breaking any
> code or modifying the current design of enumerated types, IMHO it should
> simple enough to add it as a language extension in the next rev of C++.

This sounds like a call for enum traits, which is an idea I was playing
with a couple of years ago. The intent was to make more compile time
information about enums available, and support automatic sets of
operations, including iteration.

It might be worth dusting that stuff off, revise and boost it. Any


Boost list run by bdawes at, gregod at, cpdaniel at, john at