Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2005-12-10 10:19:12

On 12/10/2005 06:55 AM, 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.
> Regards,
> Paul Mensonides

Hmm... An array *seems* "cleaner" or "more object-oriented". I only
say more "object-oriented" because switch statements were used before
there were virtual functions. However, maybe that's my prejudice, and
I'll admit "cleaner" and "more object-oriented" are pretty nebulous.

Anyway, an example of generating such a switch statement is in
vault under "Template Metaprogramming" in The
array version of the same code is in in

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