RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++Code

Learn About Using C++ rvalue References In The C++Builder BCC32 Compiler

BCC32, which is the classic C++Builder 32 bit compiler, includes the use of rvalue references, which allow creating a reference to temporaries. Also, rvalue references avoid unnecessary copying and make possible perfect forwarding functions. This feature is one of the C++11 features.

Rvalue references are a compound type like standard C++ references, which are referred to as lvalue references. An lvalue reference is formed by appending the ampersand character (&) to a type:

The syntax of an rvalue reference is to add && after a type:

An rvalue reference behaves like an lvalue reference, except that you can bind an rvalue reference to a temporary — an rvalue.

In the example above, SomeClass() is not bound to an identifier, so it is an rvalue and can be bound to an rvalue reference — but not an lvalue reference.

Here is the above sample code in C++Builder.

Find out more about C++ rvalue References over in the Embarcadero DocWiki.


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

Deep Dive Webinar: Boost C++Builder Compile Speed with TwineCompile
About author

FMXExpress.com has over 600 articles with all kinds of tips and tricks for Delphi FireMonkey on Android, IOS, OSX, Windows, and Linux.
Related posts
CodeDelphi

Quickly Build Enterprise-Grade Multi-Tier Solutions Using DataSnap In Delphi And C++

C++CodeDelphi

Easily Create A Python Container Type In Delphi And Execute It In This Windows Sample App

C++DelphiRAD Studio

Manual uninstall of RAD Studio/Delphi/C++Builder 10.4 Sydney

CodeDelphiRAD Studio

Learn How To Send Arrays To A PostgreSQL Database Server Using FireDAC In Delphi On Windows

Leave a Reply

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

IN THE ARTICLES