dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


advertisement
 

C++0x Forward Enum Declarations Cut Down Compilation Time and Dependencies

A new C++0x feature called forward enum declarations allows you to declare an enumeration without providing its enumerators list. Learn how using it can avert long compilation times and ODR violations.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


very declaration of an enum type must be a complete definition containing a full list of its enumerators. However, in some use cases declaring an enumeration without providing the enumerators list is desirable. For example, you may use a forward declaration like this...

enum class Direction;

...instead of repeating the complete definition (see below) in every translation unit.



enum class Direction: short {Up, Down};

A year ago, the C++ standards committee voted into the Working Draft a proposal to add forward declarations of enum types. This 10-Minute Solution shows how to use forward declarations of enum types to expedite compilation time and reduce code dependencies.


Your project has an enum type containing hundreds of machine-generated enumerators that change frequently. You must provide a complete definition of that enum in every translation unit, even if the compiler seemingly doesn't need the complete definition of the enum.


Replace complete definitions of enum types with forward enum declarations where possible.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

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