Browse DevX
Sign up for e-mail newsletters from DevX


Safeguard Your enums: Make Them Strongly-Typed

Find out how the newly standardized strongly-typed enum types resolve long-standing bugs and security loopholes.

num types have been a valuable asset in the arsenal of C++ programmers for many years. However, their current specification has some security loopholes that can lead to bugs and portability problems. Recently, the C++ standards committee accepted a new proposal for strongly typed enum types. As with all other C++09 proposals, it may take some time before your compiler supports this feature, but it's not a moment too soon to learn how to use this feature or how to make your code C++09-ready.

How can you avoid implicit conversions of enumerators to integral types? Or specify the exact underlying type for a certain enum?

Use C++09 strongly-typed enums.

Thanks for your registration, follow us on our social networks to keep up-to-date