]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gdc.test/compilable/test10726.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / test10726.d
1 // PERMUTE_ARGS:
2
3 public struct CirBuff(T)
4 {
5 private T[] data;
6 private size_t head = 0;
7 private size_t size = 0;
8 public size_t length() const { return size; }
9
10 public bool opEquals(CirBuff!T d) @trusted
11 {
12 if (length != d.length)
13 return false;
14 for (size_t i=0; i!=size; ++i)
15 {
16 if (this.data[(this.head+i) % this.data.length] !=
17 d.data[(d.head + i) % d.data.length])
18 {
19 return false;
20 }
21 }
22 return true;
23 }
24 }
25
26 class Once
27 {
28 Foo!Bar _bar;
29 }
30
31 class Bar
32 {
33 static Once _once;
34 mixin(sync!(Once, "_once"));
35 }
36
37 class Foo(T = int)
38 {
39 CirBuff!T _buff;
40 }
41
42 template sync(T, string U = "this", size_t ITER = 0)
43 {
44 static if (ITER == __traits(derivedMembers, T).length)
45 enum sync = "";
46 else
47 {
48 enum string mem = __traits(derivedMembers, T)[ITER];
49 enum string sync =
50 "static if(! __traits(isVirtualMethod, " ~ U ~ "." ~ mem ~ ")) { }"
51 ~ sync!(T, U, ITER+1);
52 }
53 }