Thread overview |
---|
May 31, 2016 Getting the parameters and other attributes belonging to the function overload with the greatest number of arguments | ||||
---|---|---|---|---|
| ||||
I'd like to find the overload of some function with the most parameters and (in this specific case) to get their identifiers using e.g. ParameterIdentifierTuple. There have also been cases where I'd have liked to iterate over the result of Parameters!func for each overload of that function. Can this be done, and if so how? |
May 31, 2016 Re: Getting the parameters and other attributes belonging to the function overload with the greatest number of arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to pineapple | On Tuesday, 31 May 2016 at 20:06:47 UTC, pineapple wrote: > I'd like to find the overload of some function with the most parameters and (in this specific case) to get their identifiers using e.g. ParameterIdentifierTuple. There have also been cases where I'd have liked to iterate over the result of Parameters!func for each overload of that function. Can this be done, and if so how? Yes this can be done, you must use the getOverload trait: https://dlang.org/spec/traits.html#getOverloads The result of this trait is the function itself so it's not hard to use, e.g the result can be passed directly to 'Parameters', 'ReturnType' and such library traits. |
May 31, 2016 Re: Getting the parameters and other attributes belonging to the function overload with the greatest number of arguments | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | On Tuesday, 31 May 2016 at 20:46:37 UTC, Basile B. wrote:
> Yes this can be done, you must use the getOverload trait:
>
> https://dlang.org/spec/traits.html#getOverloads
>
> The result of this trait is the function itself so it's not hard to use, e.g the result can be passed directly to 'Parameters', 'ReturnType' and such library traits.
Awesome, thank you!
|
Copyright © 1999-2021 by the D Language Foundation