Date: Sat, 25 May 2024 17:08:05 +0000
> 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.
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
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.
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:08:09