Rvalue reference
An rvalue reference is a C++ reference type, written with &&, that binds to rvalues, including temporary objects, and supports moving resources from them.
100 C++ Mistakes and How to Avoid Them
An rvalue reference is a C++ reference type that can bind to temporary or otherwise movable expressions and enable resource transfer.
- How it is used
- Uses rvalue references to transfer resources efficiently and reduce unnecessary copying in modern C++ object handling.
- How deep it goes
- Defines &&, rvalues, move constructors, and source invalidation through contrasting Page implementations, without broader language internals.
- Examples
- Uses Page and TextSection examples to contrast expensive copying with pointer transfer through Page(Page&&) and std::move.
- What you can do after
- Apply it via move constructors and move assignment operators to transfer resources while invalidating moved-from objects.
Read how 100 C++ Mistakes and How to Avoid Them explains rvalue reference →
Learn C++ by Example
An rvalue reference is a C++ reference type, written with &&, that can bind to an rvalue.
- How it is used
- Avoids unnecessary copies when inserting temporary objects into vectors.
- How deep it goes
- Explains lvalues, rvalues, overloads, and move construction, while deferring complete value-category details.
- Examples
- Uses temporary vectors, get_next_row, triangle generation, push_back overloads, and emplace_back.
- What you can do after
- Apply it via vector insertion and move construction to avoid copying temporary vectors.
Related concepts
- push_backused by · push_back is an operation that appends an element to the end of a sequence container or returns a sequence containing the appended element.
- temporary objectuses · A temporary object is an unnamed object created for an intermediate expression or initialization whose lifetime is limited by language rules.
- referencekind of · A reference is an indirect value or relationship that identifies or provides access to another value, object, resource, or source.
- rvalueconfigures · An rvalue is an expression that does not designate an assignable object and provides a value or temporary object for use in computation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

