Debian Codegraph @

gcc/testsuite/gdc.test/compilable/test14929.d

raw
1 struct HashMap(K, V)
2 {
3 V* opBinaryRight(string op)(K key) const if (op == "in")
4 {
5 size_t index;
6 foreach (ref node; buckets[index].range)
7 {
8 return &(node.value);
9 }
10 return null;
11 }
12
13 struct Node
14 {
15 K key;
16 V value;
17 }
18
19 alias Bucket = UnrolledList!(Node);
20 Bucket[] buckets;
21 }
22
23 struct UnrolledList(T)
24 {
25 Range range() const pure
26 {
27 return Range(_front);
28 }
29
30 static struct Range
31 {
32 ref T front() const @property
33 {
34 return cast(T) current.items[index];
35 }
36 void popFront() pure
37 {
38 }
39 bool empty() const pure @property
40 {
41 return true;
42 }
43 const(Node)* current;
44 size_t index;
45 }
46
47 Node* _front;
48
49 static struct Node
50 {
51 ContainerStorageType!T[10] items;
52 }
53 }
54
55 template ContainerStorageType(T)
56 {
57 alias ContainerStorageType = T;
58 }
59
60 template isComponentStorage(CS, C)
61 {
62 enum bool isComponentStorage = is(typeof(
63 (inout int = 0)
64 {
65 CS cs = CS.init;
66 ulong eid;
67 cs.add(eid, C.init);
68 }));
69 }
70
71 struct HashmapComponentStorage(ComponentType)
72 {
73 private HashMap!(ulong, ComponentType) components;
74
75 void add(ulong eid, ComponentType component)
76 {
77 assert(eid !in components);
78 }
79 }
80
81 static assert(isComponentStorage!(HashmapComponentStorage!int, int));
82
83 void main()
84 {
85 }