How to define delegate what returns ref?

Oleg B code.viator at gmail.com
Fri Aug 28 11:46:15 UTC 2020


Hello all!

syntax

     ref int delegate() foo0;

or

     ref(int) delegate() foo1;

or

     int delegate() ref foo2;

are not valid.

if I try alias

     alias refint = ref int;
     refint delegate() foo3;

foo3 have type `int delegate()` (without `ref`)
and it can't store delegate from object method that have `int 
delegate() ref` (that can be printed if we use 
`typeof(&someobject.method).stringof`)

I found only one ugly way to do this

     interface Foo { ref int func(); }
     typeof(&Foo.init.func) foo4;

How to do this more clearly?


More information about the Digitalmars-d-learn mailing list