Store any callable in an array

wjoe none at example.com
Mon May 7 02:41:41 UTC 2018


Thanks for replying.

On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
> On 05/04/2018 06:33 PM, Neia Neutuladh wrote:
>> 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.
>
> If toDelegate isn't (always) @safe, how can you be sure that 
> your wrapper is? Also, TFunc may have an unsafe destructor.
>
> That's not good use of `@trusted`.

Could you elaborate on the unsafe destructor please? Are there 
any other gotchas ?


More information about the Digitalmars-d-learn mailing list