Boost logo

Boost :

From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-12-23 18:00:57


Richard Jennings wrote:
> Here's a request for an extension to ENUM_VALUES for you to consider.
>
> 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"))

How about:

struct BlockData
{
     BlockData(std::sizt_t a_index, const char *a_description) :
         index(a_index), description(a_description)
     { }
     std::sizt_t index;
     const char *description;
};

BOOST_ENUM_VALUES(BlockType_t, BlockData,
     (SampleIfg)(BlockData(0, "Sample Interferogram"))
     (SampleSpec)(BlockData(1, "Sample Spectrum"))
)

or even better for my taste:

BOOST_ENUM_VALUES(BlockType_t, BlockData,
     (SampleIfg)({ 0, "Sample Interferogram" })
     (SampleSpec)({ 1, "Sample Spectrum" })
)

and then you don't even need to constructor of BlockData.

I'm not sure if this compiles, but I hope it does. If it doesn't, can
you make it work, Frank? If it does, then I guess it's quite nice for
you, Richard, isn't it?


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