On Fri, Dec 31, 2021 at 11:52:21AM +0000, kdevel via Digitalmars-d-learn wrote:
[...]
> That is what I want to do. The function template lyr shall be
> (explicitly) instantiated in order to put the resulting function
> pointer into an AA. The call signature of lyr!(foo) and foo must be
> the same.
> 
> In C++ this looks like this:
[...]

--------
struct R {}

void lyr(alias Fn)(ref R r)
{
        Fn(r);
}

void foo(ref R r) { }

static immutable void function(ref R)[string] reg;
shared static this() {
        // workaround for lack of CT AA initialization
        reg = [
                "foo": &foo,
                "lfoo": &lyr!foo,
        ];
}
--------


T

-- 
Why waste time reinventing the wheel, when you could be reinventing the engine? 
-- Damian Conway

Reply via email to