3 ms·
making the returned object non copyable, non movable is a an option. edit: also, the rule is simple: RVO is always mandated, NRVO remains an optimization.
by gpderetta 7y ago
making the returned object non copyable, non movable is a an option.
edit: also, the rule is simple: RVO is always mandated, NRVO remains an optimization.
- daemin 7y agoI'm not sure if C++14 or C++17 has fixed this but if the object was not copy-constructible then the compiler would emit an error if it was returned by value even if RVO/NRVO was meant to be used. I figure because semantically you need to enable copy-construction of the object.
- gpderetta 7y agoIIRC it was changed in C++14. Now in the RVO case, no copy/move constructor is required (and in fact the compiler is not allowed to call it if it exists).