This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Prohibit enum <-> int mixup


* Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> 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

Ah, looks promising: it also refuses < and > operators, exactly
what I'm looking for :)

I'll have to add --std=c++0x parameter - does that have any other
side effects I should be aware of ?


cu
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weigelt@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]