Prohibit enum <-> int mixup

Jonathan Wakely jwakely.gcc@gmail.com
Sun Jan 30 20:33:00 GMT 2011


On 30 January 2011 20:11, Enrico Weigelt wrote:
> * Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
>> Technically what is allowed is implicit conversion from enum to int.
>> In C++0x you can define a scoped enum which doesn't allow the
>> conversion.
>
> How exactly is this done ?

enum class foo { bar };

foo f = foo::bar;

int i = foo::bar;  // error, no conversion



More information about the Gcc-help mailing list