| 1 |
// https://issues.dlang.org/show_bug.cgi?id=23598 |
| 2 |
|
| 3 |
alias AliasSeq(a...) = a; |
| 4 |
|
| 5 |
static if (1) |
| 6 |
{ |
| 7 |
|
| 8 |
template sort(alias f, a...) |
| 9 |
{ |
| 10 |
static if (a.length > 0) |
| 11 |
{ |
| 12 |
alias x = f!(a[0]); |
| 13 |
alias sort = a; |
| 14 |
} |
| 15 |
else |
| 16 |
alias sort = a; |
| 17 |
} |
| 18 |
|
| 19 |
alias SortedItems = sort!(isDependencyOf, String); |
| 20 |
|
| 21 |
enum isDependencyOf(Item) = Item.DirectDependencies.length == 0; |
| 22 |
|
| 23 |
struct String |
| 24 |
{ |
| 25 |
alias DirectDependencies = AliasSeq!(); |
| 26 |
|
| 27 |
enum l = SortedItems.length; // (3) |
| 28 |
} |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
/*****************************************************/ |
| 33 |
|
| 34 |
static if (1) |
| 35 |
{ |
| 36 |
enum x = 1; |
| 37 |
enum y = 2; |
| 38 |
|
| 39 |
template f(T) |
| 40 |
{ |
| 41 |
alias b = int; |
| 42 |
static if (x) |
| 43 |
{ |
| 44 |
alias c = x; |
| 45 |
} |
| 46 |
else |
| 47 |
{ |
| 48 |
alias c = y; |
| 49 |
} |
| 50 |
|
| 51 |
static if (is(typeof(c))) |
| 52 |
{ |
| 53 |
} |
| 54 |
else |
| 55 |
{ |
| 56 |
static assert(0); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
void g() |
| 61 |
{ |
| 62 |
int x = f!int.c; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
/*****************************************************/ |
| 67 |
|
| 68 |
template forward(args...) |
| 69 |
{ |
| 70 |
template fwd(alias arg) |
| 71 |
{ |
| 72 |
alias fwd = arg; |
| 73 |
} |
| 74 |
|
| 75 |
alias Result = AliasSeq!(); |
| 76 |
static foreach (arg; args) |
| 77 |
Result = AliasSeq!(Result, fwd!arg); |
| 78 |
static if (Result.length == 1) |
| 79 |
alias forward = Result[0]; |
| 80 |
else |
| 81 |
alias forward = Result; |
| 82 |
} |
| 83 |
|
| 84 |
void func(int i, int j) |
| 85 |
{ |
| 86 |
func(forward!(i, j)); |
| 87 |
} |