Boost logo

Boost :

From: Richard Jennings (richard.jennings_at_[hidden])
Date: 2005-12-22 05:36:18


Here's a request for an extension to ENUM_VALUES for you to consider.

I need to use BOOST_ENUM_VALUES with type std::size_t so I can use the
method 'value' and use the result as an index to a vector. I would also
like to have an end-user readable description for the enumeration value.
Currently I hold this in a separate class that maps enumeration values to
descriptions.

 From what I understand, the enumeration tags have to be C++ names so no
spaces are allowed whereas end-users don't usually like CamelCase (or
whatever) unspaced C++ names.

Here's an example:
BOOST_ENUM_VALUES_DESCRIPTIONS(BlockType_t, std::size_t,
   (SampleIfg)(0)("Sample Interferogram")
   (SampleSpec)(1)("Sample Spectrum")
   (SamplePhase)(2)("Sample Phase")
   (RefIfg)(3)("Reference Interferogram"))

And then a method something like:
   const char* description() const;

Would anyone else find this useful?


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