From: Marc VIALA (mviala_at_[hidden])
Date: 2006-01-16 02:53:24
May be I've missed some messages of the thread, see message here after, but
is there any method that would return the index of the enumeration element
when using BOOST_ENUM_VALUES.
Or if not, if there any convenient way to be able to do that:
void f(ErrorType e)
case ErrorType::Warning: break;
case ErrorType::BadArg: break;
case ErrorType::Fatal: break;
I'm using BOOST_ENUM rev 4.5
Thanks in advance.
De : boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] De
la part de Richard Jennings
Envoyé : jeudi 22 décembre 2005 15:31
À : boost_at_[hidden]
Objet : Re: [boost] BOSOT_ENUM proposal rev 4, ENUM_VALUES extension?
On Thu, 22 Dec 2005 11:04:57 -0000, Frank Laub <frank.laub_at_[hidden]>
> One alternative is to do this instead:
> BOOST_ENUM_VALUES(BlockType_t, const char*,
> (SampleIfg)("Sample Interferogram")
> (SampleSpec)("Sample Spectrum")
> (SamplePhase)("Sample Phase")
> (RefIfg)("Reference Interferogram")
> One principle idea of the Boost.Enum library is to hide the fact that
> integers are really doing the dirty work. I suppose in this case we
> could expose a 'raw' or 'native' method that would return the index
> number of the enumeration element. This could then be used for your
> vector index. Would this work for you?
Yes that would work for me. I took it that the spirit of BOOST_ENUM was
indeed to hide the basic type and that you should use BOOST_ENUM_VALUES if
you wanted to be sure of the value of each enumeration.
There's always a 'but', so mine is that using BOOST_ENUM_VALUES as you
suggest requires that the enumeration values start with zero. I think
that's most cases.
Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk