Date: Sat, 06 Sep 2025 02:15:02 +0100
> Despite there is a fundamental difference between prvalue and xrvalue, yet> we are not taking advantage of that because we cannot differentiate between> them.>What advantage do you foresee taking if you could tell the difference? Can you >give 3 different examples?Yes,* a prvalue is certain to end its lifetime inside the body of the callee, while an xrvalue doesn't. This will allow to give the move operation a more precise meaning for both.* program binary size can be reduced.The current state of implementing a temporary in a call is as follow:void foo(T arg); - becomes-> { T arg{}; foo(&arg);}Which calls ~T(), outside the callee body.So if we have a million call site to foo, then there is a million deduplication of ~T().* exception wise: if the destructor of T throws an exception, then it is thrown in the context of the caller not the callee which is counter intuitive. Because a temporary exists only inside the callee.
Received on 2025-09-06 01:15:12