[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtkmm
Subject:    Re: C++11: Replacing unscoped enums with scoped enums
From:       Krzysztof_KosiƄski <tweenk.pl () gmail ! com>
Date:       2015-08-13 13:00:45
Message-ID: CAFLw2WRX-_pnftPL99UpJRiTrpve_ydaxqhbiM4gMgJiC_k_Nw () mail ! gmail ! com
[Download RAW message or body]

2015-08-13 10:56 GMT+02:00 Murray Cumming <murrayc@murrayc.com>:
> 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.

It depends on the name mangling scheme. If enums are mangled into the
function names in the same way as enum classes, then this could work.

There's also the issue of the size of underlying type: in C++11, the
underlying type is always int, but in C++03 the standard allows it to
be short or even char. GCC will generate such code If one uses
-fshort-enums, but as far as I can tell, the default is to always use
int.

Regards, Krzysztof
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic