For example:
In accepted answer https://stackoverflow.com/a/14623480/1423254,
Does copy elision and RVO would still work for classes without move constructors?
Yes, RVO still kicks in. Actually, the compiler is expected to pick: RVO (if possible)
In accepted answer https://stackoverflow.com/a/38043447/1423254,
Under non-guaranteed copy elision rules, this will create a temporary, then move from that temporary into the function's return value. That move operation may be elided, but T must still have an accessible move constructor even if it is never used.
The point is that I thought that RVO and "lvalue moves" (or how to call them) are 2 totally separate operations, but my colleague told me that for RVO to kick in, the class returned needs a move constructor. So I checked the internet and SO and obviously, the information can't be found quickly...
Aucun commentaire:
Enregistrer un commentaire