@trusting generic functions

Lodovico Giaretta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 28 05:59:36 PDT 2016


On Saturday, 28 May 2016 at 12:45:21 UTC, Era Scarecrow wrote:
>  Fourth, you could create a helper function/template that 
> cycles through a struct of your choice and tells you if any of 
> it's methods fail to be safe. This will require a little more 
> work, but it could be used as a full insurance and only 
> requires a single template call on your function to ensure the 
> safety.
>
>  I can try and make this fourth one, but this isn't something 
> I've done often.

Thank you.
This solution has the advantage of not bloating the code too 
much, but the drawback that it forces all methods of the template 
argument to be at least @trusted, and not only the methods that 
my function needs to use, so imposing a stricter-than-necessary 
limit on its use in @safe code.



More information about the Digitalmars-d-learn mailing list