c++: fix explicit/copy problem [PR109247]
[official-gcc.git] / gcc / testsuite / gdc.dg / torture / gdc35.d
blob111e05612b4b40a0e3e6bc3afb267831847009d4
1 // https://bugzilla.gdcproject.org/show_bug.cgi?id=35
2 // { dg-do run }
3 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
5 /**
6 * Here the BinaryHeap instance uses an alias parameter and therefore
7 * the instance's functions (percolateDown) need to be generated in
8 * topNIndex->BinaryHeap scope and not in the declaration scope
9 * (module->BinaryHeap).
11 void topNIndex()()
13 bool indirectLess(int a, int b)
15 return a > b;
18 auto a = BinaryHeap!(indirectLess)();
21 struct BinaryHeap(alias less)
23 void percolateDown()
25 less(0, 1);
29 void test35a()
31 topNIndex();
35 * Similar as test35a but with an additional indirection.
36 * The nested function chain for percolateDown should look like this:
37 * topNIndex2->BinaryHeap2->percolateDown.
39 void topNIndex2()()
41 bool indirectLess(int a, int b)
43 return a > b;
45 auto a = BinaryHeap2!(S35b!(indirectLess)())();
48 struct S35b(alias a)
50 void foo()
52 a(0, 0);
56 struct BinaryHeap2(alias less)
58 void percolateDown()
60 less.foo();
64 void test35b()
66 topNIndex2();
69 void main()
71 test35a();
72 test35b();