|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-12-10 07:55:55
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk