Boost logo

Boost :

Subject: Re: [boost] Enums: naming question?
From: Vicente Botet (vicente.botet_at_[hidden])
Date: 2011-03-19 16:12:40


Jeffrey Lee Hellrung, Jr.-2 wrote:
>
> On Sat, Mar 19, 2011 at 4:20 AM, Vicente Botet
> <vicente.botet_at_[hidden]>wrote:
>
>>
>> Jeffrey Lee Hellrung, Jr.-2 wrote:
>>
> [...]
>
>> > Do you mean that
>> > the
>> > scoping_type maps the "native enum" type of the (emulated) scoped enum
>> > back
>> > to the (emulated) scoped enum? I.e., native_type and scoping_type are
>> > inverse metafunctions?
>>
>> Yes.
>>
>
> Then all I can suggest as a better name is *maybe* scoped_type or
> scoped_enum_type. But scoping_type might be fine.
>

Hmm, scoping_type and scoped_enum_type seems reasonable, but I prefer yet
the use of native_type. What do others think?

>> Beman has created his scoped enum emulation just for this purpose, but it
>> lacks some scoped enum features as it is implicitly convertible to the
>> underlying type.
>>
>
> How is it otherwise different from your implementation? Does it use
> simpler
> syntax or fewer (meta-)functions?
>

Extracted from the file boost/detail/scoped_enum_emulation.hpp:

// Caution: only the syntax is emulated; the semantics are not emulated and
// the syntax emulation doesn't include being able to specify the
underlying
// representation type.
//
// The emulation is via struct rather than namespace to allow use within
classes.
// Thanks to Andrey Semashev for pointing that out.
//
// Helpful comments and suggestions were also made by Kjell Elster, Phil
Endecott,
// Joel Falcou, Mathias Gaunard, Felipe Magno de Almeida, Matt Calabrese,
Vincente
// Botet, and Daniel James.
//
// Sample usage:
//
// BOOST_SCOPED_ENUM_START(algae) { green, red, cyan };
BOOST_SCOPED_ENUM_END
// ...
// BOOST_SCOPED_ENUM(algae) sample( algae::red );
// void foo( BOOST_SCOPED_ENUM(algae) color );
// ...
// sample = algae::green;
// foo( algae::cyan );

and here the emulation code

# define BOOST_SCOPED_ENUM_START(name) struct name { enum enum_type
# define BOOST_SCOPED_ENUM_END };
# define BOOST_SCOPED_ENUM(name) name::enum_type

The syntax is similar, but the used type is BOOST_SCOPED_ENUM(name) for
Beman design and name in mine.

Best,
Vicente

--
View this message in context: http://boost.2283326.n4.nabble.com/Enums-naming-question-tp3388473p3390196.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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