The base type.
The desired linkage of the result type.
The desired FunctionAttributes of the result type.
alias ExternC(T) = SetFunctionAttributes!(T, "C", functionAttributes!T); auto assumePure(T)(T t) if (isFunctionPointer!T || isDelegate!T) { enum attrs = functionAttributes!T | FunctionAttribute.pure_; return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t; } int f() { import core.thread : getpid; return getpid(); } int g() pure @trusted { auto pureF = assumePure(&f); return pureF(); } assert(g() > 0);
Constructs a new function or delegate type with the same basic signature as the given one, but different attributes (including linkage).
This is especially useful for adding/removing attributes to/from types in generic code, where the actual type name cannot be spelt out.