Store any callable in an array

Neia Neutuladh neia at ikeran.org
Sat May 5 00:30:35 UTC 2018


On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
> If toDelegate isn't (always) @safe, how can you be sure that 
> your wrapper is?

If it were @safe, the compiler would accept it.

Looking at the code, I believe there are several casts that the 
compiler can't verify but are used safely.

> Also, TFunc may have an unsafe destructor.

If it's a delegate with an un- at safe destructor (how would that 
work? a captured context variable?), then it's already not @safe. 
If it's a function, it doesn't have a destructor. If it's a 
user-defined type with opCall, that's something to pay attention 
to, but it's beyond the scope of the original question.


More information about the Digitalmars-d-learn mailing list