Quick Q: What are copy elision and return value optimization?

Quick A: a way to remove copying objects in certain case, improving performance and reducing the constraints on a class (no copy or move needed).

Recently on SO:

What are copy elision and return value optimization?

Copy elision is an optimization implemented by most compilers to prevent extra (potentially expensive) copies in certain situations. It makes returning by value or pass-by-value feasible in practice (restrictions apply).

It's the only form of optimization that elides (ha!) the as-if rule - copy elision can be applied even if copying/moving the object has side-effects...

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.