`static` function ... cannot access variable in frame of ...
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 15 23:06:00 UTC 2024
On Monday, 15 January 2024 at 22:23:27 UTC, Bastiaan Veelo wrote:
> On Monday, 15 January 2024 at 18:43:43 UTC, user1234 wrote:
>> The two calls are not equivalent.
>
>> so what is passed as alias need to be static too.
>
> Thanks all. I thought a static member function just isn't able
> to access the instance of the struct, but as I understand now
> it is static all the way.
>
> What I am looking for is a way to have different structs that
> have a member function that has the same name in all of them,
> that is callable without a this pointer, and able to take an
> alias argument. That is probably asking too much.
As a workaround, you can alias the outer function in the struct:
```d
struct S
{
alias foo = S_foo;
}
```
This might be less than ideal, but at least it works.
-Steve
More information about the Digitalmars-d-learn
mailing list