| 1 |
void main() |
| 2 |
{ |
| 3 |
alias Zoo = Foo!(1); |
| 4 |
} |
| 5 |
|
| 6 |
struct Foo(size_t N) |
| 7 |
{ |
| 8 |
string bar() |
| 9 |
{ |
| 10 |
Appender!(string) w; |
| 11 |
char[] buf; put(w, buf); |
| 12 |
return ""; |
| 13 |
} |
| 14 |
|
| 15 |
public bool opEquals(T)(T other) const |
| 16 |
// Add const, different from bug 10056 |
| 17 |
{ |
| 18 |
alias Foo!(typeof(this), T, "CMP") P; |
| 19 |
return false; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
template Foo(T, U, string OP) |
| 24 |
{ |
| 25 |
static if (T.ISEMPTY && U.ISEMPTY) |
| 26 |
enum bool S = false; |
| 27 |
else |
| 28 |
enum bool S = false; |
| 29 |
|
| 30 |
alias Foo = Foo!(0); |
| 31 |
} |
| 32 |
|
| 33 |
/**********************************************/ |
| 34 |
|
| 35 |
void put(R, E)(ref R r, E e) |
| 36 |
{ |
| 37 |
static if (is(typeof(r.put(e)))) |
| 38 |
{ |
| 39 |
r.put(e); |
| 40 |
} |
| 41 |
else |
| 42 |
{ |
| 43 |
static assert(false, "Cannot put a "~E.stringof~" into a "~R.stringof); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
struct Appender(A : T[], T) |
| 48 |
{ |
| 49 |
private template canPutItem(U) |
| 50 |
{ |
| 51 |
enum bool canPutItem = is(U : T); |
| 52 |
} |
| 53 |
private template canPutRange(R) |
| 54 |
{ |
| 55 |
enum bool canPutRange = is(typeof(Appender.init.put(R.init[0]))); |
| 56 |
} |
| 57 |
|
| 58 |
void put(U)(U item) if (canPutItem!U) |
| 59 |
{ |
| 60 |
char[T.sizeof == 1 ? 4 : 2] encoded; |
| 61 |
put(encoded[]); |
| 62 |
} |
| 63 |
void put(R)(R items) if (canPutRange!R) |
| 64 |
{ |
| 65 |
} |
| 66 |
} |