advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 3/5 | Rate this item | 2 users have rated this item.
 

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. 


advertisement
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 decltype to 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 decltype operator to extract the return type from an expression instead of spelling it out explicitly.

  Next Page: The Point of No return
Page 1: IntroductionPage 3: Type Querying
Page 2: The Point of No return 
Please rate this item (5=best)
 1  2  3  4  5
advertisement