Debian Codegraph @

vendor/Heap-Layers/wrappers/stlallocator.h

raw symbols SCIP
1 // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/wrappers/stlallocator.h`/
2
3 /*
4
5 Heap Layers: An Extensible Memory Allocation Infrastructure
6
7 Copyright (C) 2000-2020 by Emery Berger
8 http://www.emeryberger.com
9 [email protected]
10
11 Heap Layers is distributed under the terms of the Apache 2.0 license.
12
13 You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 */
17
18 #ifndef HL_STLALLOCATOR_H
19 #define HL_STLALLOCATOR_Hcxx . . $ `vendor/Heap-Layers/wrappers/stlallocator.h:19:9`!
20
21 #include <cstdio>
22 #include <new>
23 #include <cstdlib>
24 #include <limits>
25
26 #include <memory> // STL
27
28 // Somewhere someone is defining a max macro (on Windows),
29 // and this is a problem -- solved by undefining it.
30
31 #if defined(max)
32 #undef max
33 #endif
34
35 using namespace std;
36
37 /**
38 * @class STLAllocator
39 * @brief An allocator adapter for STL.
40 *
41 * This mixin lets you use any Heap Layers allocator as the allocator
42 * for an STL container.
43 *
44 * Example:
45 * <TT>
46 * typedef STLAllocator<int, MyHeapType> MyAllocator;<BR>
47 * list<int, MyAllocator> l;<BR>
48 * </TT>
49 */
50
51 namespace HLcxx . . $ HL/ {
52
53 template <class T, class Super>
54 class STLAllocatorcxx . . $ HL/STLAllocator# : public Super {
55 public:
56
57 typedef T value_typecxx . . $ HL/STLAllocator#value_type#;
58 typedef T * pointercxx . . $ HL/STLAllocator#pointer#;
59 typedef const T * const_pointercxx . . $ HL/STLAllocator#const_pointer#;
60 typedef T& referencecxx . . $ HL/STLAllocator#reference#;
61 typedef const T& const_referencecxx . . $ HL/STLAllocator#const_reference#;
62 typedef stdcxx . . $ std/::size_tcxx . . $ std/size_t# size_typecxx . . $ HL/STLAllocator#size_type#;
63 typedef stdcxx . . $ std/::ptrdiff_tcxx . . $ std/ptrdiff_t# difference_typecxx . . $ HL/STLAllocator#difference_type#;
64 typedef stdcxx . . $ std/::true_type propagate_on_container_move_assignmentcxx . . $ HL/STLAllocator#propagate_on_container_move_assignment#;
65
66 template <class U>
67 struct rebindcxx . . $ HL/STLAllocator#rebind# {
68 typedef STLAllocatorcxx . . $ HL/STLAllocator#<U,Super> othercxx . . $ HL/STLAllocator#rebind#other#;
69 };
70
71 pointercxx . . $ HL/STLAllocator#pointer# addresscxx . . $ HL/STLAllocator#address(f1476124d98bcd95). (referencecxx . . $ HL/STLAllocator#reference# x) const {
72 return &cxx . . $ std/`operator&`(3fbb01592cd53f2a).x;
73 }
74
75 const_pointercxx . . $ HL/STLAllocator#const_pointer# addresscxx . . $ HL/STLAllocator#address(b9eaa428dabef0). (const_referencecxx . . $ HL/STLAllocator#const_reference# x) const {
76 return &cxx . . $ std/`operator&`(3fbb01592cd53f2a).x;
77 }
78
79 STLAllocatorcxx . . $ HL/STLAllocator#`STLAllocator<T, Super>`(49f6e7a06ebc5aa8).() throw() {
80 }
81
82 STLAllocatorcxx . . $ HL/STLAllocator#`STLAllocator<T, Super>`(187e74e302806f4a). (const STLAllocator& s) throw()
83 : Super (s)
84 {}
85
86 virtual ~cxx . . $ HL/STLAllocator#`~STLAllocator<T, Super>`(49f6e7a06ebc5aa8).STLAllocator() throw() {
87 }
88
89 /// Make the maximum size be the largest possible object.
90 size_typecxx . . $ HL/STLAllocator#size_type# max_sizecxx . . $ HL/STLAllocator#max_size(fe4d2d262d4164a8).() const
91 {
92 return stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<std::size_t>::maxcxx . . $ std/numeric_limits#max(f708dce9a8856c70).() / sizeof(T);
93 }
94
95 #if defined(_WIN32)
96 char * _Charalloc (size_type n) {
97 return (char *) allocate (n);
98 }
99 #endif
100
101 #if defined(__SUNPRO_CC)
102 inline void * allocate (size_type n,
103 const void * = 0) {
104 if (n) {
105 return reinterpret_cast<void *>(Super::malloc (sizeof(T) * n));
106 } else {
107 return (void *) 0;
108 }
109 }
110 #else
111 inline pointercxx . . $ HL/STLAllocator#pointer# allocatecxx . . $ HL/STLAllocator#allocate(ec542951d71c8d4e). (size_typecxx . . $ HL/STLAllocator#size_type# n,
112 const void * = 0) {
113 if (n) {
114 return reinterpret_cast<pointercxx . . $ HL/STLAllocator#pointer#>(Super::malloc (sizeof(T) * n));
115 } else {
116 return 0;
117 }
118 }
119 #endif
120
121 inline void deallocatecxx . . $ HL/STLAllocator#deallocate(5500c4293b1bbef0). (void * p, size_typecxx . . $ HL/STLAllocator#size_type#) {
122 Super::free (p);
123 }
124
125 inline void deallocatecxx . . $ HL/STLAllocator#deallocate(afd8256c216b84b2). (pointercxx . . $ HL/STLAllocator#pointer# p, size_typecxx . . $ HL/STLAllocator#size_type#) {
126 Super::free (p);
127 }
128
129 #if __cpluspluscxx . . $ `<built-in>:449:9`! >= 201103L
130 // Updated API from C++11 to work with move constructors
131 template<class U, class... Args>
132 void constructcxx . . $ HL/STLAllocator#construct(d331963632abed63). (U* p, Args&&... args) {
133 new((void *) p) U(stdcxx . . $ std/::forwardcxx . . $ std/forward(f1f6a9b4566963a8).<Args>(args)...);
134 }
135
136 template<class U>
137 void destroycxx . . $ HL/STLAllocator#destroy(7e6e718d4f0ca9be). (U* p) {
138 p->~U();
139 }
140
141 #else
142 // Legacy API for pre-C++11
143 void construct (pointer p, const T& val) {
144 new ((void *) p) T (val);
145 }
146
147 void destroy (pointer p) {
148 ((T*)p)->~T();
149 }
150
151 #endif
152
153 template <class U> STLAllocatorcxx . . $ HL/STLAllocator#`STLAllocator<T, Super>`(8f54676ea6991b42). (const STLAllocatorcxx . . $ HL/STLAllocator#<U, Super> &) throw()
154 {
155 }
156
157 };
158
159 template <typename T, class S>
160 inline bool operatorcxx . . $ HL/`operator!=`(fef5daa2f5cf3d2).!=(const STLAllocatorcxx . . $ HL/STLAllocator#<T,S>& a, const STLAllocatorcxx . . $ HL/STLAllocator#<T,S>& b) {
161 return (&cxx . . $ std/`operator&`(3fbb01592cd53f2a).a !=cxx . . $ HL/`operator!=`(fef5daa2f5cf3d2). &cxx . . $ std/`operator&`(3fbb01592cd53f2a).b);
162 }
163
164 template <typename T, class S>
165 inline bool operatorcxx . . $ HL/`operator==`(fef5daa2f5cf3d2).==(const STLAllocatorcxx . . $ HL/STLAllocator#<T,S>& a, const STLAllocatorcxx . . $ HL/STLAllocator#<T,S>& b) {
166 return (&cxx . . $ std/`operator&`(3fbb01592cd53f2a).a ==cxx . . $ HL/`operator==`(fef5daa2f5cf3d2). &cxx . . $ std/`operator&`(3fbb01592cd53f2a).b);
167 }
168
169
170 }
171
172
173 #endif