|
Boost : |
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-08-20 13:30:48
Hi Iain,
> At its most simple, it's a way to stop function users providing difficult to detect
> erroneous data
Have you seen the proposed "enum class" ? http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
I think that this could solve the problem that you're addressing, but
I'm not certain if operator| is defined in a useful way for "enum
class" - does anyone know? Until/unless this is adopted, maybe some
macro-magic could be used to implement it, e.g.
ENUM_CLASS(foo) { ENUM(foo_1,1<<0) , ENUM(foo_2,1<<1) };
This would need to expand to an enum wrapped in a class, as described
in section 2.1 of the doc linked above. I'm not certain if this can be
done with macros, but the Boost preprocessor library has lots of magic
that would help.
(The doc says this has been implemented in MS VC++ 8.0 beta, but I'm
unclear whether that means that it's in the public version of that
compiler, or whether someone at Microsoft has implemented it privately
- does anyone know?)
Regards,
Phil.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk