
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Yuval Ronen
to:
class Boolean_base { public: enum type { False, True, size = 2, Invalid = -1 };
protected: typedef boost::array<const char*, (size)+1> array_type; static const array_type& storage() { static const array_type names = { "False", "True", "2" }; return names; } }; typedef safe_enum<Boolean_base> Boolean;
A few small remarks:
I doubt if the storage array needs to be 'size+1' large. The last element of the size itself doesn't need to be stringized.
I haven't really been following this conversion, but why do you need an array at all? You have a sequence containing enumerator names. You can generate a switch statement just as easily as you can the enum itself: switch (v) { case False: return "False"; case True: return "True"; // etc. Regards, Paul Mensonides