+ 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
4 Respostas
+ 1
CarrieForle (怎麼這麼多學生帳號?) hmm... It should invoke the move constructor, is the compiler doing any optimization here?
+ 1
CarrieForle (怎麼這麼多學生帳號?) Oh... Thank you for answering, have a nice day ahead ;)
0
There is no move constructor nor copy constructor invoked? Putting cout in different constructors show that only auto_ptr(T*) invoked twice.
0
I guess yes, it's copy elision if I'm not wrong:
https://stackoverflow.com/questions/12953127/what-are-copy-elision-and-return-value-optimization