ADT.h
847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef ADT
#define ADT
#ifdef WITH_NAMESPACE
namespace llvm {
#endif
template <unsigned Alignment, unsigned Size>
struct AlignedCharArray {
alignas(Alignment) char buffer[Size];
};
template <typename T1>
class AlignerImpl {
T1 t1;
};
template <typename T1>
union SizerImpl {
char arr1[sizeof(T1)];
};
template <typename T1>
struct AlignedCharArrayUnion
: AlignedCharArray<alignof(AlignerImpl<T1>), sizeof(SizerImpl<T1>)> {};
template <typename T, unsigned N>
struct SmallVectorStorage {
AlignedCharArrayUnion<T> InlineElts[N];
};
template <typename T, unsigned N>
class SmallVector : SmallVectorStorage<T, N> {};
template <typename T>
struct OptionalStorage {
AlignedCharArrayUnion<T> storage;
};
template <typename T>
class Optional {
OptionalStorage<T> Storage;
};
#ifdef WITH_NAMESPACE
} // namespace llvm
#endif
#endif