How does this work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How does this work?

In the code attached here, how does line 85 call the move constructor instead of copy constructor? Like 91 calling the move assignment instead of copy assignment operator makes sense to me, because it's an rvalue. But I don't understand line 85 calling move constructor. Plz explain this. Thank you :) https://code.sololearn.com/cfFZlJ2BwfNP/?ref=app

10th Aug 2021, 2:24 AM
Rishi
Rishi - avatar
4 Answers
+ 1
CarrieForle (怎麼這麼多學生帳號?) hmm... It should invoke the move constructor, is the compiler doing any optimization here?
10th Aug 2021, 7:49 AM
Rishi
Rishi - avatar
+ 1
CarrieForle (怎麼這麼多學生帳號?) Oh... Thank you for answering, have a nice day ahead ;)
10th Aug 2021, 1:27 PM
Rishi
Rishi - avatar
0
There is no move constructor nor copy constructor invoked? Putting cout in different constructors show that only auto_ptr(T*) invoked twice.
10th Aug 2021, 4:17 AM
你知道規則,我也是
你知道規則,我也是 - avatar
10th Aug 2021, 10:04 AM
你知道規則,我也是
你知道規則,我也是 - avatar