1 #ifndef STRUCTURES_H 2 #define STRUCTURES_H 3 4 extern "C" { 5 extern int printf(const char *restrict, ...); 6 } 7 8 struct Val {int X; void g(); }; 9 10 struct MutableVal { 11 void constFun(int) const; 12 void nonConstFun(int, int); 13 void constFun(MutableVal &) const; 14 void constParamFun(const MutableVal &) const; 15 void nonConstParamFun(const MutableVal &); 16 int X; 17 }; 18 19 struct NonTriviallyCopyable { 20 NonTriviallyCopyable() = default; 21 // Define this constructor to make this class non-trivially copyable. 22 NonTriviallyCopyable(const NonTriviallyCopyable& Ntc); 23 int X; 24 }; 25 26 struct TriviallyCopyableButBig { 27 int X; 28 char Array[16]; 29 }; 30 31 struct S { 32 typedef MutableVal *iterator; 33 typedef const MutableVal *const_iterator; 34 const_iterator begin() const; 35 const_iterator end() const; 36 const_iterator cbegin() const; 37 const_iterator cend() const; 38 iterator begin(); 39 iterator end(); 40 }; 41 42 struct T { 43 typedef int value_type; 44 struct iterator { 45 value_type &operator*(); 46 const value_type &operator*() const; 47 iterator& operator ++(); 48 bool operator!=(const iterator &other); 49 void insert(value_type); 50 value_type X; 51 }; 52 iterator begin(); 53 iterator end(); 54 }; 55 56 struct Q { 57 typedef int value_type; 58 struct const_iterator { 59 value_type &operator*(); 60 const value_type &operator*() const; 61 const_iterator &operator++(); 62 bool operator!=(const const_iterator &other); 63 void insert(value_type); 64 value_type X; 65 }; 66 struct iterator { 67 operator const_iterator() const; 68 }; 69 iterator begin(); 70 iterator end(); 71 }; 72 73 struct U { 74 struct iterator { 75 Val& operator*(); 76 const Val& operator*()const; 77 iterator& operator ++(); 78 bool operator!=(const iterator &other); 79 Val *operator->(); 80 }; 81 iterator begin(); 82 iterator end(); 83 int X; 84 }; 85 86 struct X { 87 S Ss; 88 T Tt; 89 U Uu; 90 S getS(); 91 }; 92 93 template<typename ElemType> 94 class dependent { 95 public: 96 dependent<ElemType>(); 97 struct iterator_base { 98 const ElemType& operator*()const; 99 iterator_base& operator ++(); 100 bool operator!=(const iterator_base &other) const; 101 const ElemType *operator->() const; 102 }; 103 104 struct iterator : iterator_base { 105 ElemType& operator*(); 106 iterator& operator ++(); 107 ElemType *operator->(); 108 }; 109 110 typedef iterator_base const_iterator; 111 const_iterator begin() const; 112 const_iterator end() const; 113 iterator begin(); 114 iterator end(); 115 unsigned size() const; 116 ElemType & operator[](unsigned); 117 const ElemType & operator[](unsigned) const; 118 ElemType & at(unsigned); 119 ElemType & at(unsigned, unsigned); 120 const ElemType & at(unsigned) const; 121 122 // Intentionally evil. 123 dependent<ElemType> operator*(); 124 125 void foo(); 126 void constFoo() const; 127 }; 128 129 template<typename First, typename Second> 130 class doublyDependent{ 131 public: 132 struct Value { 133 First first; 134 Second second; 135 }; 136 137 struct iterator_base { 138 const Value& operator*()const; 139 iterator_base& operator ++(); 140 bool operator!=(const iterator_base &other) const; 141 const Value *operator->() const; 142 }; 143 144 struct iterator : iterator_base { 145 Value& operator*(); 146 Value& operator ++(); 147 Value *operator->(); 148 }; 149 150 typedef iterator_base const_iterator; 151 const_iterator begin() const; 152 const_iterator end() const; 153 iterator begin(); 154 iterator end(); 155 }; 156 157 template<typename Contained> 158 class transparent { 159 public: 160 Contained *at(); 161 Contained *operator->(); 162 Contained operator*(); 163 }; 164 165 template<typename IteratorType> 166 struct Nested { 167 typedef IteratorType* iterator; 168 typedef const IteratorType* const_iterator; 169 IteratorType *operator->(); 170 IteratorType operator*(); 171 iterator begin(); 172 iterator end(); 173 const_iterator begin() const; 174 const_iterator end() const; 175 }; 176 177 // Like llvm::SmallPtrSet, the iterator has a dereference operator that returns 178 // by value instead of by reference. 179 template <typename T> 180 struct PtrSet { 181 struct iterator { 182 bool operator!=(const iterator &other) const; 183 const T operator*(); 184 iterator &operator++(); 185 }; 186 iterator begin() const; 187 iterator end() const; 188 }; 189 190 template <typename T> 191 struct TypedefDerefContainer { 192 struct iterator { 193 typedef T &deref_type; 194 bool operator!=(const iterator &other) const; 195 deref_type operator*(); 196 iterator &operator++(); 197 }; 198 iterator begin() const; 199 iterator end() const; 200 }; 201 202 template <typename T> 203 struct RValueDerefContainer { 204 struct iterator { 205 typedef T &&deref_type; 206 bool operator!=(const iterator &other) const; 207 deref_type operator*(); 208 iterator &operator++(); 209 }; 210 iterator begin() const; 211 iterator end() const; 212 }; 213 214 namespace Macros { 215 216 struct MacroStruct { 217 int Arr[10]; 218 }; 219 static MacroStruct *MacroSt; 220 #define CONT MacroSt-> 221 222 } // namespace Macros 223 224 #endif // STRUCTURES_H 225