Let's say I have a generic function that uses pointers. It will be inferred @system by the compiler, but I know that the pointer usage can be @trusted. The problem is that if I declare the function @trusted, I'm also implicitly trusting any call to @system methods of the template parameter.

Dumb example (pointer usage can be trusted, but doSomething may not):

auto doSomethingDumb(T)(ref T t) // I want it @trusted if doSomething is at least @trusted
    {
        T* pt = &t;
        return pt.doSomething();
    }

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.

Lodovico Giaretta

Reply via email to