static function and access frame
Ali Çehreli
acehreli at yahoo.com
Tue Jan 23 22:33:31 UTC 2018
On 01/23/2018 01:51 PM, Alex wrote:
> Ok, I'm quite sure, I overlooked something.
>
> First version, working
>
> [code]
> void main()
> {
> auto s = S();
> auto t = T!s();
> t.fun;
> }
> struct S { void fun(){} }
> struct T(alias s){ auto fun() { s.fun; } }
> [/code]
>
> Now, the fun method of struct T has to become static and the problems
> begin:
> Error: static function app.main.T!(s).T.fun cannot access frame of
> function D main
Good news: Works at least with 2.078 as it should:
void main()
{
auto s = S();
auto t = T!s();
t.fun;
}
struct S { static void fun(){} }
struct T(alias s){ auto fun() { s.fun; } }
Ali
More information about the Digitalmars-d-learn
mailing list