@trusting generic functions

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


On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
>  Use traits..
>
> https://dlang.org/phobos/std_traits.html#isSafe
>
> so your function becomes (i believe)
>
>
>     auto doSomethingDumb(T)(ref T t) if(isSafe!(T))

The problem is that T is a type, and I should check for safety of 
every method of T that I'm using in my function. This does not 
scale well, and if I change the body of the function to use a new 
method, I may forget to add it to the isSafe checks.


More information about the Digitalmars-d-learn mailing list