Two functions with different args. Taking address of the one
Виталий Фадеев
vital.fadeev at gmail.com
Thu Mar 11 13:46:44 UTC 2021
On Thursday, 11 March 2021 at 13:14:56 UTC, Paul Backus wrote:
> On Thursday, 11 March 2021 at 12:56:34 UTC, Виталий Фадеев
> wrote:
>> [...]
>
> Something like this:
>
> template Overloads(alias symbol)
> {
> static if (__traits(compiles, __traits(parent, symbol)))
> alias Overloads = __traits(getOverloads,
> __traits(parent, symbol),
> __traits(identifier, symbol)
> );
> else
> alias Overloads = symbol;
> }
>
> auto getOverloadFor(alias fun, T)()
> {
> foreach (overload; Overloads!fun)
> static if (__traits(compiles, (T arg) {
> overload(arg); }))
> return &overload;
> }
>
> Usage:
>
> __processMouseKey = getOverloadFor!(process, MouseKeyEvent);
Thanks a lot, bro!
More information about the Digitalmars-d-learn
mailing list