C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::elide

From: Lénárd Szolnoki <cpp_at_[hidden]>
Date: Sat, 25 May 2024 18:26:34 +0100
On 25 May 2024 18:08:05 BST, Tiago Freire via Std-Proposals <std-proposals_at_[hidden]> wrote:
>> I've never needed RVO nor NRVO with an unmovable-and-uncopyable type.
>
>I think that you are perhaps focusing too much on unmovable and uncopiable types. You want to do something to an object before returning it, and still have the benefit of RVO.
>
>I don't believe the original introduction of guaranteed RVO in C++17 had that in mind either, it was an optimization (that worked more like a calling convention) that guarantees RVO for all types because that made everything much more efficient.

https://open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0135r0.html

The "Why should copy elision be mandatory?" lists immovable types as the first reason.

>
>
>While unmovable/uncopiable types may raise questions related to the design, remove that restriction, and examples are pretty much everywhere.
>I believe every single code could benefit from an RVO extension, as creating things in place will be cheaper than moving or copying, and you get that behavior for immovable objects as a side effect.
>
>My 2c

Received on 2024-05-25 17:26:42