Talk:cpp/language/reference
From cppreference.com
[edit] rvalue references
Hi, everyone! If a function has lvalue reference to const and rvalue reference overloads, which overload will bind to xvalue? I wrote a test code and run, but I'm still confused. {
... int b ; //the definition of f can be found in [1] f (std::move (b)) ; //call f (const int &) f (std::move (5)) ; //call f (int &&) ...
}
- xvalues are just a subdivision of rvalues (as described in cpp/language/value_category). Rvalues bind to rvalue references as mentioned on this page. I'll make a mention. --Cubbi (talk) 18:57, 29 December 2015 (PST)
- Oh, f (std::move (b)) now calls f (int &&) instead of f (const int &), which is not the same as last time. Maybe I coded something wrond or misread the output.
[edit] universal references
Universal references need to be added to this article. I'll do it some time later, maybe Yanpas (talk) 06:49, 10 January 2017 (PST)
- their correct name is "forwarding references", and are currently mentioned in std::forward and template argument deduction. I agree though, they deserve a brief paragraph here (use correct names, and remember to mention their auto&& form (and the contexts in which it is forwarding and contexts in which it isn't - n3922 is the important exception) in addition to the T&& form) --Cubbi (talk) 06:57, 10 January 2017 (PST)