Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++RAD Studio

Learn How To Use Return Type Deduction In C++ For Windows Apps

learn-how-to-use-return-type-deduction-in-c

In this tutorial, you will learn how to use return type deduction in C++ Builder. For the C++14 scheme of auto with functions, the compiler can deduce return types for any function, no matter how complex it is. The only requirement is that each return statement needs have the same type. The practices are identical as for auto variables.

To deduce the type, the compiler requires to detect the function definition right ahead. That means this technique is limited to function templates, inline functions, and helper functions which are applied only inside a particular translation unit.

Here is a code example on return type deduction

So, return type deduction bypasses undesirable conversions and the removes type changes you must to apply.

If there is a possibility to use return type deduction, just apply this technique. Because this can assist to secure the types you utilize more consistently.

Check out more modern C++ features over here on GitHub


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Software Developer | B.Tech-CSE at AUT | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified | Udacity Alumni
Related posts
C++Code

This Week's Favorite Modern C++ Picks On LearnCPlusPlus.org

DelphiDeveloper InterviewsInterviewNews

What Is It Like To Be A Developer Joe C. Hecht?

C++CodeRAD Studio

In C++ - Fantastic Ball Physics And Wonderful Wide Strings

C++CodeDelphiTech Partner

How To Add Website Metrics To Your Apps Right Now

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES