What ever happened to move semantics?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Feb 28 14:34:23 UTC 2024
On 29/02/2024 3:17 AM, Timon Gehr wrote:
> 12. Regarding lifetimes.
>
> You make a point about nested functions and lambdas. However, this is
> not the only problem. Consider:
>
> |struct S{ int x; } int foo()@safe{ S s; scope p = &s.x; bar(s); // last
> use of s, moved return *p; // bad memory access }|
I've been exploring this problem recently with isolated.
What this suggests to me is that all move operator supporting types are
implicitly isolated.
Both s and p would belong to the same subgraph, when s gets moved, the
subgraph that s and p are in would get invalidated making the return not
possible.
Interesting, there appears to be some inter-relationship here that I had
not considered.
More information about the Digitalmars-d
mailing list