Escape this in pure members
Jacob Carlborg
doob at me.com
Sat Sep 19 18:48:31 UTC 2020
On 2020-09-19 18:07, Per Nordlöw wrote:
> If an aggregate member is pure but not scope when can it escape the
> `this` pointer?.
>
> Only via return?
I'm not sure if returning the `this` pointer is considered escaping it.
The caller already had access to it. Under the hood, the `this` pointer
is just another argument passed to the function.
> In the struct and class case?
A nested class seems to be able to escape the `this` reference:
class Foo
{
Bar b;
class Bar
{
void bar() pure
{
b = this;
}
}
}
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list