Login | Register   
RSS Feed
Download our iPhone app
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.


Clean Up Function Syntax Mess with decltype

The funky syntax of a function's return type isn't just unreadable in many cases—it's also a common source of maintenance problems. However, with the new decltype operator your functions will look much cleaner and easier to maintain.




Application Security Testing: An Integral Part of DevOps

he auto keyword presented here is related to another C++09 proposal: the decltype operator. decltype(e) retrieves the type of the expression e. By combining decltype and auto, you can simplify complex function declarations and reduce maintenance costs. The following sections will show you how to use decltypeto make your functions sing.

Your function consists of a simple return statement. Alas, the manual declaration of a complex return type makes your code brittle and illegible.

Use the decltypeoperator to extract the return type from an expression instead of spelling it out explicitly.

Comment and Contribute






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



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