@nogc deduction for templated functions
Eugene Wissner
belka at caraus.de
Sat Nov 18 17:46:03 UTC 2017
On Saturday, 18 November 2017 at 17:28:14 UTC, David Zhang wrote:
> Hi,
>
> Is there a way for a templated function to deduce or apply the
> @safe/@nogc attributes automaticaly? I feel like I remember dmd
> doing so at one point, but it doesn't appear to work anymore.
> In particular, I need to call a function belonging to a
> templated type, but do not know what attributes are applied.
>
> eg.
>
> void func(T)(T t)
> {
> //Don't know if safe or nogc
> t.someFunc();
> }
>
> Thanks.
If you instantiate "func" the compiler should correctly infer
the attributes. Do you have any code where it doesn't work?
More information about the Digitalmars-d-learn
mailing list