What are some useful uses for rvalue reference ( && )? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What are some useful uses for rvalue reference ( && )?

26th Jun 2016, 6:04 PM
Garme Kain
Garme Kain - avatar
4 Answers
+ 1
Though rvalue references only became part of the standard starting from C++11 and are therefore not covered by SoloLearn C++, here's my answer: rvalue references are a means to prevent unnecessary copying of data and therefore a means to optimize memory and speed. Therefore rvalue references start to shine whenever a big, clunky object needs to be copied. Instead of the classic copy, rvalues (input parameters) objects are considered temporary such that you can rip out their guts such that they only can be destroyed properly and transfer them to another object. So there you have it: it's another means to efficiently copy an object into another one.
26th Jun 2016, 7:12 PM
Stefan
Stefan - avatar
0
So, sololearn doesnt cover c++11? itd be nice if an updated version is created. c++11 really does introduce a lot of things.
26th Jun 2016, 7:14 PM
Garme Kain
Garme Kain - avatar
0
Yeah you are right, Garme, but as you might have seen, a lot of people here in the forums struggle with the basics in syntax, problem solving and best practices (many questions in the quiz are actually bad practices but might still teach operator precedence etc.). SoloLearn C++ is still a start and not a too bad one either.
26th Jun 2016, 7:21 PM
Stefan
Stefan - avatar
0
I second that. It is a good tool, but for begginers though. Anyways, i like this app. The amount of interaction is great!
26th Jun 2016, 7:23 PM
Garme Kain
Garme Kain - avatar