c++ - standards compliant way to typedef my enums -


How can I get rid of Enum without warning, without scoping properly? The standard compatible code will be to compare with foo :: bar :: mUpload (see), but the apparent scope is really long and make the darn stuff unreadable.

Maybe there is another way that does not use typedef? I do not want to modify enum - I have not written it and used it in elsewhere.

Warning C4482: Non standard is used: enum 'foo :: bar :: baz' is used in the qualified name

  Name space foo {class bar {enum baz {mUpload = 0, mDownload}; }} Typedef foo :: bar :: baz mode_t; Mode_t mode = getMode (); If (mode == mode_t :: mUpload) // C4482 {return uploaded (); } And (emphasis (mode == mode_t :: MD download); // C4482 return downloadthingy ();}  

If defined in a class, it is best that you can do this to bring the class to its realm and just use class_name :: value or Define the type-F of the class. In C ++ 03 values ​​of an enum are part of the enclosed area (which is the square in your case). In C ++ 0x / 11, you have the name of Enum The values ​​will be able to qualify:

  name space first {naming place second {struct enclosing {enum the_enum {one_value, another};}}} first: second :: attaching ; First typedef :: second :: enclosing the_enclosing; insists (attached :: one_value! = The_enclosing :: second);  

In the future, your usage will be correct (C ++ 11) :

  typedef first :: second :: enclosing :: the_enum my_enum; emphasis (my_enum :: one_value! = My_enum :: another);  

Comments