|
Boost : |
From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-12-10 10:09:07
Paul Mensonides wrote:
> I haven't really been following this conversion, but why do you need an array at
> all? You have a sequence containing enumerator names. You can generate a
> switch statement just as easily as you can the enum itself:
>
> switch (v) {
> case False:
> return "False";
> case True:
> return "True";
> // etc.
I guess that's a possibility...
One point in favour of array, is that it ensures us of O(1) lookup time.
A good compiler might do that with switch/case but I'm not sure it's
something that we can rely on. My knowledge in these compiler
optimization issues is definitely not that extended.
For the _VALUES version, BTW, an array won't cut it, because the numbers
aren't nicely ordered from 0 to size - 1. It needs to a map, or a
switch/case, and I'm not really sure which is better...
Yuval
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk