How to check if a class has a specific overload for member x?
pascal111
judas.the.messiah.111 at gmail.com
Tue Aug 2 00:16:54 UTC 2022
On Monday, 1 August 2022 at 00:23:21 UTC, Hipreme wrote:
> On Sunday, 31 July 2022 at 19:25:51 UTC, Hipreme wrote:
>> [...]
>
>
> Seems that is how it should be checked:
>
> ```d
> enum hasOverload(T, string member, FuncType)()
> {
> bool ret;
> static foreach(overload; __traits(getVirtualMethods, T,
> member))
> if(is(typeof(overload) == FuncType) &&
> !__traits(isAbstractFunction, overload))
> ret = true;
> return ret;
> }
> ```
It's like checking if a word used in a text with more than one
definition according the dictionary.
More information about the Digitalmars-d-learn
mailing list