Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Reference (C++)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Rvalue reference === The declaration of the form: <Type>&& <Name> where <code><Type></code> is a type and <code><Name></code> is an identifier is said to define an identifier whose type is '''[[rvalue reference]] to <code><Type></code>'''. Since the name of an [[Value (computer science)#lrvalue|rvalue]] reference is itself an lvalue, <code>std::move</code> must be used to pass an rvalue reference to a function overload accepting an rvalue reference parameter. Rvalue references to cv-unqualified type template parameters of that same function template or <code>auto&&</code> except when deduced from a brace-enclosed initializer list are called '''forwarding references''' (referred to as "universal references" in some older sources<ref>{{cite web|url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4164.pdf|title=Forwarding References|last1=Sutter|first1=Herb|last2=Stroustrup|first2=Bjarne|last3=Dos Reis|first3=Gabriel}}</ref>) and can act as lvalue or rvalue references depending on what is passed to them.<ref>[[#cpp-std|ISO/IEC 14822]], clause 13.10.2.1, paragraph 3.</ref> When found in function parameters, they are sometimes used with <code>std::forward</code> to forward the function argument to another function while preserving the value category (lvalue or rvalue) it had when passed to the calling function.<ref>{{cite web|url=http://thbecker.net/articles/rvalue_references/section_01.html|title=C++ Rvalue References Explained|last=Becker|first=Thomas|accessdate=2022-11-25}}</ref> Types which are of kind "reference to <code><Type></code>" are sometimes called '''reference types'''. Identifiers which are of reference type are called '''reference variables'''. To call them ''variable'', however, is in fact a misnomer, as we will see.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)