Presentation about r-value references and move semantics in the new C++0x standard of C++ language. In the presentation I talk about motivation for it and using and performance impact of it.
@fortysixfish Thank you for question. Answer is: If your function is called as rvalue reference (RVO is not applied), C++ calls destructor as obvious on function's str object - but before destructor is called, str object is moved (stollen) to object from calling code - so then local str object is null or some garbish and it is fine to destruct ;) If you don't still understand me, feel free to ask me again :)
This was excellent, thank you! One question I have: If you have a function, std::string returnSomeString() { std::string str("Hello"); return str; } wouldn't a temporary be required since str goes out of block and has destructor called?
@fortysixfish Thank you for question. Answer is: If your function is called as rvalue reference (RVO is not applied), C++ calls destructor as obvious on function's str object - but before destructor is called, str object is moved (stollen) to object from calling code - so then local str object is null or some garbish and it is fine to destruct ;) If you don't still understand me, feel free to ask me again :)
LucasFranchesco 7 months ago
This was excellent, thank you! One question I have: If you have a function, std::string returnSomeString() { std::string str("Hello"); return str; } wouldn't a temporary be required since str goes out of block and has destructor called?
fortysixfish 7 months ago