C++11: Replacing unscoped enums with scoped enums
- From: Murray Cumming <murrayc murrayc com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: C++11: Replacing unscoped enums with scoped enums
- Date: Thu, 13 Aug 2015 10:56:11 +0200
C++11 lets us use this:
enum class SomeEnum
{
VALUE_A,
VALUE_B
}
instead of the old way:
enum SomeEnum
{
SOME_ENUM_VALUE_A,
SOME_ENUM_VALUE_B
}
So, you'd then use SomeEnum::VALUE_A instead of SOME_ENUM_VALUE_A.
That's nicer, avoids some namespace pollution, and also lets us declare
the type without defining it.
However, I guess we can't just replace enum with "enum class" without
breaking ABI, right? I don't mind so much about breaking API.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]