Store any callable in an array
ag0aep6g
anonymous at example.com
Fri May 4 19:12:16 UTC 2018
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`.
More information about the Digitalmars-d-learn
mailing list