@trusting generic functions

Lodovico Giaretta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 31 00:31:42 PDT 2016


On Sunday, 29 May 2016 at 18:02:53 UTC, Steven Schveighoffer 
wrote:
> You can create a trusted expression by using a lambda and 
> immediately calling it. ag0aep6g brought it up.
>
> I would write it like this (untested, but I think this works):
>
> return (()@trusted => &t)().doSomething();
>
> The key is to limit your code that is tainted by @trusted to as 
> little code as possible.

This does indeed solve the problem without replicating code and 
costraints.
It allows to just trust the parts of the function that can be 
trusted.

Thank you very much.

Lodovico Giaretta




More information about the Digitalmars-d-learn mailing list