Question about alias and getOverloads
uranuz
neuranuz at gmail.com
Tue Jan 28 19:59:15 UTC 2020
Thanks for advice ;) This looks like some `standard trick` that
is yet not learnt or forgoten by me personally. The key was in
using `parent` trait. This is what I failed to think of. This is
working as expected:
//-----
import std;
import core.thread;
import std.meta: AliasSeq;
void foo(string param1) {}
void foo(string param1, int param2, bool param3) {}
template Bar(alias Func)
{
alias Bar = __traits(getOverloads, __traits(parent, Func),
__traits(identifier, Func));
}
void main()
{
import std.traits: fullyQualifiedName, Parameters;
import std.conv: text;
static foreach( It; Bar!foo ) {
pragma(msg, fullyQualifiedName!It ~ "/" ~
(Parameters!It).length.text);
}
}
//-----
Output:
onlineapp.foo/1
onlineapp.foo/3
//-----
So as far as I understand alias template parameter gives access
to all of items of overload set as I was expecting. The only
problem is that I didn't found something about it in
specification about templates:
https://dlang.org/spec/template.html
More information about the Digitalmars-d-learn
mailing list