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