| |
| Posted by Hipreme in reply to Hipreme | PermalinkReply |
|
Hipreme
Posted in reply to Hipreme
| On Sunday, 31 July 2022 at 19:25:51 UTC, Hipreme wrote:
> I wish to generate some functions using mixin template and I wish to check if the current class already has an specific overload with parameters (A, B).
What I'm currently trying is doing __traits(getOverloads, T, "foo") , and then checking if its type are equal. But it seems hackish, and I would like to make something like hasOverload!(Test, "foo", int(int a, int b) const) or something like that.
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;
}
```
|