Add macros for the "enum class" concept?

Should we add preprocessor stuff to conditionally use the C++11 "enum class" construct? #if Whatever #define BOOST_HAVE_ENUM_CLASS #endif //... #if BOOST_HAVE_ENUM_CLASS #define BOOST_ENUM_CLASS( Name ) enum class Name #define BOOST_ENUM_CLASS_BASE( Name, Type ) enum class Name : Type #define BOOST_ENUM_CLASS_REFER( Type, Enumerator ) (Type :: Enumerator) #else #define BOOST_ENUM_CLASS( Name ) enum Name #define BOOST_ENUM_CLASS_BASE( Name, Type ) BOOST_ENUM_CLASS( Name ) #define BOOST_ENUM_CLASS_REFER( Type, Enumerator ) (Enumerator) #endif I'm not sure that the second version of BOOST_ENUM_CLASS_BASE is the best alternative. Nor do I know if the parentheses around enumerators are best. You can use BOOST_ENUM_CLASS in an enum definition header and BOOST_ENUM_CLASS_BASE as a header or a forward declaration. Since enumerators can be scoped, BOOST_ENUM_CLASS_REFER encapsulates the need to add the enum type's name.

On 12 December 2011 12:46, Daryle Walker <darylew@hotmail.com> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum class" construct?
We have something like that already: http://www.boost.org/boost/detail/scoped_enum_emulation.hpp

Date: Mon, 12 Dec 2011 12:55:33 +0000 From: dnljms@gmail.com
On 12 December 2011 12:46, Daryle Walker <darylew@hotmail.com> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum class" construct?
We have something like that already:
Reading it, it doesn't have any base type and/or forward-declaration facilities.

Daryle Walker wrote
Date: Mon, 12 Dec 2011 12:55:33 +0000 From: dnljms@
On 12 December 2011 12:46, Daryle Walker <darylew@> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum
class" construct?
We have something like that already:
Reading it, it doesn't have any base type and/or forward-declaration facilities.
How do you want to be able to use forward declaration in a portable way? There are also scoped enums with underlying type that are no enum class. These could be added as well. Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Add-macros-for-the-enum-class-concept-tp4... Sent from the Boost - Dev mailing list archive at Nabble.com.

Vicente Botet wrote
Daryle Walker wrote
Date: Mon, 12 Dec 2011 12:55:33 +0000 From: dnljms@
On 12 December 2011 12:46, Daryle Walker <darylew@> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum
class" construct?
We have something like that already:
Reading it, it doesn't have any base type and/or forward-declaration facilities.
How do you want to be able to use forward declaration in a portable way?
There are also scoped enums with underlying type that are no enum class. These could be added as well.
How do you think we can use scoped enum with underlying types in a portable way? I guess the use that states that an enum is a char expect the sizeof this enum to be the same as the sizeof char, isn't it? I have been working a little bit on a enums library that provides such a feature (see https://svn.boost.org/svn/boost/sandbox/enums/libs/enums/doc/html/index.html). Let me know if you are interested. Vicente Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Add-macros-for-the-enum-class-concept-tp4... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Mon Dec 12 2011, Vicente Botet <vicente.botet-AT-wanadoo.fr> wrote:
Daryle Walker wrote
Date: Mon, 12 Dec 2011 12:55:33 +0000 From: dnljms@
On 12 December 2011 12:46, Daryle Walker <darylew@> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum
class" construct?
We have something like that already:
Reading it, it doesn't have any base type and/or forward-declaration facilities.
How do you want to be able to use forward declaration in a portable way?
There are also scoped enums with underlying type that are no enum class.
Not in C++11. There are unscoped enums with underlying type, but the way you get scoping is to use "enum class." -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote
on Mon Dec 12 2011, Vicente Botet <vicente.botet-AT-wanadoo.fr> wrote:
Daryle Walker wrote
Date: Mon, 12 Dec 2011 12:55:33 +0000 From: dnljms@
On 12 December 2011 12:46, Daryle Walker <darylew@> wrote:
Should we add preprocessor stuff to conditionally use the C++11 "enum
class" construct?
We have something like that already:
Reading it, it doesn't have any base type and/or forward-declaration facilities.
How do you want to be able to use forward declaration in a portable way?
There are also scoped enums with underlying type that are no enum class.
Not in C++11. There are unscoped enums with underlying type, but the way you get scoping is to use "enum class."
You are right. I don't know why I thought that there was the possibility to declare an scoped enum that has implicit conversion to the underlying type. My bad. IMO scope and convertibility are orthogonal. Do you know why this combination was not retained? Thanks, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Add-macros-for-the-enum-class-concept-tp4... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Thu Dec 15 2011, Vicente Botet <vicente.botet-AT-wanadoo.fr> wrote:
IMO scope and convertibility are orthogonal. Do you know why this combination was not retained?
I'm afraid that I don't even understand your question... but even if I did, I'm pretty sure I wouldn't know the answer. -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Le 17/12/11 23:12, Dave Abrahams a écrit :
on Thu Dec 15 2011, Vicente Botet<vicente.botet-AT-wanadoo.fr> wrote:
IMO scope and convertibility are orthogonal. Do you know why this combination was not retained? I'm afraid that I don't even understand your question... but even if I did, I'm pretty sure I wouldn't know the answer.
Why C++11 doesn't supports scoped enums with underlying type that are implicitly convertible to the underlying type? Vicente

on Sun Dec 18 2011, "Vicente J. Botet Escriba" <vicente.botet-AT-wanadoo.fr> wrote:
Le 17/12/11 23:12, Dave Abrahams a écrit :
on Thu Dec 15 2011, Vicente Botet<vicente.botet-AT-wanadoo.fr> wrote:
IMO scope and convertibility are orthogonal. Do you know why this combination was not retained? I'm afraid that I don't even understand your question... but even if I did, I'm pretty sure I wouldn't know the answer.
Why C++11 doesn't supports scoped enums with underlying type that are implicitly convertible to the underlying type?
You're asking the wrong guy. I suggest finding out who wrote the standard proposals (you can find the paper and credits at http://open-std.org). -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (5)
-
Daniel James
-
Daryle Walker
-
Dave Abrahams
-
Vicente Botet
-
Vicente J. Botet Escriba