On Friday, 4 May 2018 at 15:36:29 UTC, wjoe wrote:
I have a class that I want to be able to register callbacks and I'd like to be able to register any callable - functions, delegates, lambdas, anything.

Is there another way to do it besides converting those toDelegate, which states a bug with @safe functions?

Or better store each type in their own array ?


auto asDelegate(TFunc)(TFunc func) @trusted
    import std.functional : toDelegate;
    return toDelegate(func);

The "@trusted" means that you promise this thing is safe, even if the compiler can't be certain.

Reply via email to