Best way to make a template function conditionally @trusted

ikod igor.khasilev at gmail.com
Fri Apr 2 19:49:30 UTC 2021


On Thursday, 1 April 2021 at 22:35:01 UTC, tsbockman wrote:
> Suppose I have a templated struct member function for which I 
> can compute at compile-time when the function is memory safe, 
> and when it is not. But, the compiler cannot correctly 
> determine this automatically.

Compiler should be able to derive safety of templated functions. 
You may just omit @safe/@trusted. But there are some rules and 
restrictions: 
https://dlang.org/spec/function.html#function-attribute-inference


More information about the Digitalmars-d-learn mailing list