Boost logo

Boost :

Subject: Re: [boost] Enums: naming question?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-03-18 23:51:53


On Fri, Mar 18, 2011 at 5:55 PM, Vicente Botet <vicente.botet_at_[hidden]>wrote:

>
> Jeffrey Lee Hellrung, Jr.-2 wrote:
> >
> > On Fri, Mar 18, 2011 at 2:10 PM, Vicente Botet
> > &lt;vicente.botet_at_[hidden]&gt;wrote:
> >
> >> Hi,
> >>
> >> I'm developing a scoped enum library that use an emulation wrapping the
> >> native enum on a class to get scoped enumerators.
> >>
> >> I need some traits, to get the native type from the emulation, and the
> >> coping class from the native one.
> >> In addition there is an underlying type that is used to store the
> >> enumerators. Next follows the names I have use in the library:
> >>
> >> native_type::type
> >> underlying_type::type
> >> scoping_type::type
>
[...]

> >> If you need more details you can take a look in the sandbow/enums
> >> directory
> >>
> http://svn.boost.org/svn/boost/sandbox/enums/libs/enums/doc/html/index.html
>
[...]

> > Perhaps you can summarize what these types and (meta-)functions are
> > suppose
>
[...]

> When scoped enum classes are available we can use
>
> enum class EnumClass : short {E1, ... En};
>
> In this case the scoped enum class is already an enum.
>
> is_enum::value is true
> typedef EnumClass EnumClassNative;
> native_type::type is EnumClass
> underlying_type::type is short
> scoping_type::type is EnumClass
>
>
> When scoped enum classes is not supported the emulation uses the well known
> schema
>
> template
> class EnumClass
> {
> public:
> //! c++98 enum type
> typedef enum {E1, ... En} type;
> //! underlying type
> typedef short underlying_type;
> private:
> underlying_type val_;
> ...
> };
>
> and of course EnumClass is not an enum :(
>
> is_enum::value is false
> typedef EnumClass::type EnumClassNative;
> native_type::type is EnumClassNative
> underlying_type::type is short
> scoping_type::type is EnumClass
>
> Let me know if you need more details.
>
>
Thanks, that helps, I think:

So native_type is an enum type; why did you change the name from enum_type?
Maybe native_enum_type would be better?

I get underlying_type. Consider underlying_integral_type, to distinguish it
from the "underlying enum" type...although it's longer :/ It just seems
that native_type and underlying type almost sound like the same thing, and I
could imagine easily getting confused.

So what's with scoping_type? In the one case, it's the scoped enum, and in
the other case, it's the emulated scoped enum, but in both it looks like an
identity operation. I don't get the point.

- Jeff


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