@@ -37,6 +37,17 @@ class _LIBCPP_TEMPLATE_VIS allocator<void>
37
37
38
38
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
39
39
};
40
+
41
+
template <>
42
+
class _LIBCPP_TEMPLATE_VIS allocator<const void>
43
+
{
44
+
public:
45
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
46
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
47
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type;
48
+
49
+
template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;};
50
+
};
40
51
#endif
41
52
42
53
// This class provides a non-trivial default constructor to the class that derives from it
@@ -69,7 +80,6 @@ template <class _Tp>
69
80
class _LIBCPP_TEMPLATE_VIS allocator
70
81
: private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> >
71
82
{
72
-
static_assert(!is_const<_Tp>::value, "std::allocator does not support const types");
73
83
static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
74
84
public:
75
85
typedef size_t size_type;
@@ -148,6 +158,84 @@ class _LIBCPP_TEMPLATE_VIS allocator
148
158
#endif
149
159
};
150
160
161
+
template <class _Tp>
162
+
class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
163
+
: private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> >
164
+
{
165
+
static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
166
+
public:
167
+
typedef size_t size_type;
168
+
typedef ptrdiff_t difference_type;
169
+
typedef const _Tp value_type;
170
+
typedef true_type propagate_on_container_move_assignment;
171
+
typedef true_type is_always_equal;
172
+
173
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
174
+
allocator() _NOEXCEPT = default;
175
+
176
+
template <class _Up>
177
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
178
+
allocator(const allocator<_Up>&) _NOEXCEPT { }
179
+
180
+
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
181
+
const _Tp* allocate(size_t __n) {
182
+
if (__n > allocator_traits<allocator>::max_size(*this))
183
+
__throw_bad_array_new_length();
184
+
if (__libcpp_is_constant_evaluated()) {
185
+
return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp)));
186
+
} else {
187
+
return static_cast<const _Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)));
188
+
}
189
+
}
190
+
191
+
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
192
+
void deallocate(const _Tp* __p, size_t __n) {
193
+
if (__libcpp_is_constant_evaluated()) {
194
+
::operator delete(const_cast<_Tp*>(__p));
195
+
} else {
196
+
_VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
197
+
}
198
+
}
199
+
200
+
// C++20 Removed members
201
+
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
202
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
203
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
204
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
205
+
_LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference;
206
+
207
+
template <class _Up>
208
+
struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
209
+
typedef allocator<_Up> other;
210
+
};
211
+
212
+
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
213
+
const_pointer address(const_reference __x) const _NOEXCEPT {
214
+
return _VSTD::addressof(__x);
215
+
}
216
+
217
+
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17
218
+
const _Tp* allocate(size_t __n, const void*) {
219
+
return allocate(__n);
220
+
}
221
+
222
+
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT {
223
+
return size_type(~0) / sizeof(_Tp);
224
+
}
225
+
226
+
template <class _Up, class... _Args>
227
+
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
228
+
void construct(_Up* __p, _Args&&... __args) {
229
+
::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
230
+
}
231
+
232
+
_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY
233
+
void destroy(pointer __p) {
234
+
__p->~_Tp();
235
+
}
236
+
#endif
237
+
};
238
+
151
239
template <class _Tp, class _Up>
152
240
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
153
241
bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4