alias & local function
Basile B.
b2.temp at gmx.com
Mon May 10 01:26:53 UTC 2021
On Monday, 10 May 2021 at 01:25:10 UTC, Alain De Vos wrote:
> This does not:
> ```
> import std.stdio;
> void main()
> {
> int afunction(int x){return x;};
it's not static so -> context -> delegate
> alias myint = int;
> myint i=5;
> alias tfunction = int function(int);
> tfunction f = & afunction;
> writeln(f(1));
> }
> ```
> It gives compile error :
> Error: cannot implicitly convert expression &afunction of type
> int delegate(int x) pure nothrow @nogc @safe to int
> function(int)
add static in the second case.
More information about the Digitalmars-d-learn
mailing list