Boost logo

Boost :

From: Peter Simons (simons_at_[hidden])
Date: 2002-05-19 15:29:37


Dirk Gerrits writes:

> It would be nicer if there were a cleaner way to make enums with
> gaps in the values work 'naturally'.

The lambda example in the current documentation hardly serves any
purpose except for making g++ compile for a minute on an Athlon 2 GHz
machine. :-) It was my own first attempt at using meta-programming
techniques, so I guess the code got a bit out of hand.

Seriously, though, I do have a pretty clear vision of how "gapped"
enmus could be represented. I just didn't want to put too much effort
into that topic before the rest of the interface stabilizes somewhat.
My guess is that it would be best to have the developer provide some
sort of mapping table, basically an array of the enum-labels in the
correct order:

    enum foo { state1 = 2, state2 = 8, state3 = 50 };
    foo bar[] =
        {
        state1,
        state2,
        state3
        };

Then the framework could look-up the "current" value in that table,
increment the index appropriately, and retrieve the result value. I
just have to figure out a way how to represent that information
without the developer having to actually specify that array. Maybe
Boost.Preprocessor can help ... maybe there's a natural structure that
just hasn't come to my mind yet. Any suggestion is, of course, very
much appreciated!

        -peter


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk