Return-value optimization is a compiler technique to avoid copying an object that a function returns as its value, including avoiding creation of a temporary object. This optimization permits a function to efficiently return large objects while also simplifying the function’s interface and eliminating scope for issues such as resource leaks. However, there are situations where a compiler may be unable to perform this optimization, where a function does not capitalize on the optimization, and where it may be acceptable or even be better to forego this optimization.