Boost logo

Boost :

Subject: Re: [boost] Answers re BENUM library for automated enum streaming
From: Marcus Lindblom (macke_at_[hidden])
Date: 2008-09-16 05:50:28

Tony D wrote:
> Hi all,
> Markus: apologies for not including the full URL. The file is at
> Full URL is h - note Google Chrome mistakes it for a query, but the vault CGI doesn't seem to cope with %3D/%26 encoding of = and &.
> Thorsten / Marcus: roughly comparing to smart enum proposal:
> - BENUM _automates_ conversions based on stringified source code,
> which (postulating an extra macro "BENUM" hard-coding your favourite
> selection of meta-data container and optional features) allows
> BENUM(X, A = 1, B, C = 22, D = B|N);
> to approximate
> enum X { A = 1, B, C = 22, D = B|N };
> and needs no further code to be streamable etc (preprocessor macros allow
> run-time cross-referencing of stringified source code with array of actual values)


However, is it possible to define a separate mapping if one would like?

For instance, I like my strings to be lower case, and without prefixes,
whereas my enums need a bit more scaffolding:

enum Context { CXT_APP, CXT_PHYS, CXT_VIS }
enum Aspect { ASP_APP, ASP_PHYS}
CXT_APP = "app", CXT_PHYS = "phys", etc.
ASP_APP = "app", ASP_PHYS = "phys", etc.

> - smart enums requires user-maintained "meta-data" - from the smart enum docs:
> bool init = (::EnumIO<Foo>::the() (Bar, "bar") (Baz, "baz")), true;

EnumIO only does that, and it hides the usage of EnumIO<> from the
header file, thus it is very lean and efficient.

How much extra template code is instantiated in each source file
including BENUM-use?


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