How do I assign attributes of a function to another function?

Stanislav Blinov stanislav.blinov at gmail.com
Fri Nov 5 18:03:06 UTC 2021


On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote:
> I am creating a templated object that is a storehouse for a 
> heap object and executes their methods and returns an array of 
> results. With the help of a template, I want to achieve this, 
> but I want to assign the same attributes to the function. How 
> can one pass the attributes of a function to another function?

There's https://dlang.org/spec/traits.html#getFunctionAttributes 
. Or you could define your functions as function templates, 
letting the compiler infer attributes. Especially as it looks 
like you function's attributes may not be made the same as the 
ones you defer to: since you're allocating with the GC, your 
function cannot be @nogc even if a deferred one can.


More information about the Digitalmars-d-learn mailing list