]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/compilable/test10056.d
Add D front-end, libphobos library, and D2 testsuite.
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / test10056.d
1 void main()
2 {
3 alias Zoo = Foo10056!(false, false, 1);
4 }
5
6 struct Foo10056(bool S, bool L, size_t N)
7 {
8 string bar()
9 {
10 Appender10056!(string) w;
11 char[] buf; put10056(w, buf);
12 return "";
13 }
14
15 public bool opEquals(T)(T other) //const
16 //If you add const, also fails to compile with 2.062.
17 {
18 alias Foo10056!(typeof(this), T, "CMP") P;
19 return false;
20 }
21 }
22
23 template Foo10056(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 Foo10056 = Foo10056!(false, false, 0);
31 }
32
33 /**********************************************/
34
35 void put10056(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 Appender10056(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(Appender10056.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 }