| 1 |
struct S { |
| 2 |
static int foo()() { return 0; } |
| 3 |
static int foo()(int n) { return 1; } |
| 4 |
static int foo(string s) { return 2; } |
| 5 |
enum foo(int[] arr) = arr.length; |
| 6 |
} |
| 7 |
|
| 8 |
alias AliasSeq(T...) = T; |
| 9 |
|
| 10 |
alias allFoos = AliasSeq!(__traits(getOverloads, S, "foo", true)); |
| 11 |
|
| 12 |
static assert(allFoos.length == 4); |
| 13 |
|
| 14 |
static assert(allFoos[0]("") == 2); |
| 15 |
static assert(allFoos[1]() == 0); |
| 16 |
static assert(allFoos[2](1) == 1); |
| 17 |
alias foo3 = allFoos[3]; |
| 18 |
static assert(foo3!([]) == 0); |
| 19 |
|
| 20 |
static assert(S.foo() == 0); |
| 21 |
static assert(S.foo(1) == 1); |
| 22 |
static assert(S.foo("") == 2); |
| 23 |
static assert(S.foo!([]) == 0); |
| 24 |
|
| 25 |
|
| 26 |
alias fooFuns = AliasSeq!(__traits(getOverloads, S, "foo")); |
| 27 |
static assert(fooFuns.length == 1); |
| 28 |
static assert(fooFuns[0]("") == 2); |