@trusting generic functions

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat May 28 04:57:09 PDT 2016


On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote:
> Is there any way around this? Any way to declare a function 
> @trusted as long as the methods of the template argument are at 
> least @trusted?
>
> Thank you in advance.

  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))


More information about the Digitalmars-d-learn mailing list