+ 2
The overloaded constructor for rvalue reference is not getting invoked. Why ?
Check out the simple code.. https://code.sololearn.com/cIDjYxzs7QHA/?ref=app
8 ответов
+ 3
So you mean to say. There are some optimizations going on in my code.
+ 3
Pasting MyClass{MyClass{MyClass{MyClass{10}}}} to my code must invoke the constructor 4 times but it gets invoked only one time.
Hence, I am 99.9% sure now it's optimization
+ 2
Well. I also think it is some optimization done by the compiler, to avoid :
MyClass{MyClass{MyClass{MyClass{10}}}}
+ 2
MyClass class_5 = MyClass{10};
MyClass class_6 = MyClass{std::move(class_5)};
But, the upper one one Works as expected
+ 1
i think it because of copy elision..