@@ -151,13 +151,13 @@ using __is_always_equal _LIBCPP_NODEBUG =
151
151
152
152
// __allocator_traits_rebind
153
153
template <class _Tp , class _Up , class = void >
154
- struct __has_rebind_other : false_type {} ;
154
+ inline const bool __has_rebind_other_v = false ;
155
155
template <class _Tp , class _Up >
156
- struct __has_rebind_other <_Tp, _Up, __void_t <typename _Tp::template rebind<_Up>::other> > : true_type {} ;
156
+ inline const bool __has_rebind_other_v <_Tp, _Up, __void_t <typename _Tp::template rebind<_Up>::other> > = true ;
157
157
158
- template <class _Tp , class _Up , bool = __has_rebind_other <_Tp, _Up>::value >
158
+ template <class _Tp , class _Up , bool = __has_rebind_other_v <_Tp, _Up> >
159
159
struct __allocator_traits_rebind {
160
- static_assert (__has_rebind_other <_Tp, _Up>::value , " This allocator has to implement rebind" );
160
+ static_assert (__has_rebind_other_v <_Tp, _Up>, " This allocator has to implement rebind" );
161
161
using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
162
162
};
163
163
template <template <class , class ...> class _Alloc , class _Tp , class ... _Args, class _Up >
@@ -175,53 +175,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_
175
175
176
176
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
177
177
178
- // __has_allocate_hint
178
+ // __has_allocate_hint_v
179
179
template <class _Alloc , class _SizeType , class _ConstVoidPtr , class = void >
180
- struct __has_allocate_hint : false_type {} ;
180
+ inline const bool __has_allocate_hint_v = false ;
181
181
182
182
template <class _Alloc , class _SizeType , class _ConstVoidPtr >
183
- struct __has_allocate_hint <
183
+ inline const bool __has_allocate_hint_v <
184
184
_Alloc,
185
185
_SizeType,
186
186
_ConstVoidPtr,
187
- decltype ((void )std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))>
188
- : true_type {};
187
+ decltype ((void )std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))> = true;
189
188
190
- // __has_construct
189
+ // __has_construct_v
191
190
template <class , class _Alloc , class ... _Args>
192
- struct __has_construct_impl : false_type {} ;
191
+ inline const bool __has_construct_impl = false ;
193
192
194
193
template <class _Alloc , class ... _Args>
195
- struct __has_construct_impl < decltype (( void )std::declval<_Alloc>().construct(std::declval<_Args>()...)),
196
- _Alloc,
197
- _Args...> : true_type {} ;
194
+ inline const bool
195
+ __has_construct_impl< decltype (( void )std::declval<_Alloc>().construct(std::declval<_Args>()...)), _Alloc, _Args...> =
196
+ true ;
198
197
199
198
template <class _Alloc , class ... _Args>
200
- struct __has_construct : __has_construct_impl<void , _Alloc, _Args...> {} ;
199
+ inline const bool __has_construct_v = __has_construct_impl<void , _Alloc, _Args...>;
201
200
202
- // __has_destroy
201
+ // __has_destroy_v
203
202
template <class _Alloc , class _Pointer , class = void >
204
- struct __has_destroy : false_type {} ;
203
+ inline const bool __has_destroy_v = false ;
205
204
206
205
template <class _Alloc , class _Pointer >
207
- struct __has_destroy <_Alloc, _Pointer, decltype (( void )std::declval<_Alloc>().destroy(std::declval<_Pointer>()))>
208
- : true_type {} ;
206
+ inline const bool
207
+ __has_destroy_v<_Alloc, _Pointer, decltype (( void )std::declval<_Alloc>().destroy(std::declval<_Pointer>()))> = true ;
209
208
210
- // __has_max_size
209
+ // __has_max_size_v
211
210
template <class _Alloc , class = void >
212
- struct __has_max_size : false_type {} ;
211
+ inline const bool __has_max_size_v = false ;
213
212
214
213
template <class _Alloc >
215
- struct __has_max_size <_Alloc, decltype ((void )std::declval<_Alloc&>().max_size())> : true_type {} ;
214
+ inline const bool __has_max_size_v <_Alloc, decltype ((void )std::declval<_Alloc&>().max_size())> = true ;
216
215
217
- // __has_select_on_container_copy_construction
216
+ // __has_select_on_container_copy_construction_v
218
217
template <class _Alloc , class = void >
219
- struct __has_select_on_container_copy_construction : false_type {} ;
218
+ inline const bool __has_select_on_container_copy_construction_v = false ;
220
219
221
220
template <class _Alloc >
222
- struct __has_select_on_container_copy_construction <
221
+ inline const bool __has_select_on_container_copy_construction_v <
223
222
_Alloc,
224
- decltype ((void )std::declval<_Alloc>().select_on_container_copy_construction())> : true_type {} ;
223
+ decltype ((void )std::declval<_Alloc>().select_on_container_copy_construction())> = true ;
225
224
226
225
_LIBCPP_SUPPRESS_DEPRECATED_POP
227
226
@@ -272,16 +271,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
272
271
return __a.allocate (__n);
273
272
}
274
273
275
- template <class _Ap = _Alloc, __enable_if_t <__has_allocate_hint <_Ap, size_type, const_void_pointer>::value , int > = 0 >
274
+ template <class _Ap = _Alloc, __enable_if_t <__has_allocate_hint_v <_Ap, size_type, const_void_pointer>, int > = 0 >
276
275
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
277
276
allocate (allocator_type& __a, size_type __n, const_void_pointer __hint) {
278
277
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
279
278
return __a.allocate (__n, __hint);
280
279
_LIBCPP_SUPPRESS_DEPRECATED_POP
281
280
}
282
- template <class _Ap = _Alloc,
283
- class = void ,
284
- __enable_if_t <!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int > = 0 >
281
+ template <class _Ap = _Alloc, __enable_if_t <!__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int > = 0 >
285
282
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
286
283
allocate (allocator_type& __a, size_type __n, const_void_pointer) {
287
284
return __a.allocate (__n);
@@ -304,52 +301,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
304
301
__a.deallocate (__p, __n);
305
302
}
306
303
307
- template <class _Tp , class ... _Args, __enable_if_t <__has_construct <allocator_type, _Tp*, _Args...>::value , int > = 0 >
304
+ template <class _Tp , class ... _Args, __enable_if_t <__has_construct_v <allocator_type, _Tp*, _Args...>, int > = 0 >
308
305
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
309
306
construct (allocator_type& __a, _Tp* __p, _Args&&... __args) {
310
307
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
311
308
__a.construct (__p, std::forward<_Args>(__args)...);
312
309
_LIBCPP_SUPPRESS_DEPRECATED_POP
313
310
}
314
- template <class _Tp ,
315
- class ... _Args,
316
- class = void ,
317
- __enable_if_t <!__has_construct<allocator_type, _Tp*, _Args...>::value, int > = 0 >
311
+ template <class _Tp , class ... _Args, __enable_if_t <!__has_construct_v<allocator_type, _Tp*, _Args...>, int > = 0 >
318
312
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
319
313
construct (allocator_type&, _Tp* __p, _Args&&... __args) {
320
314
std::__construct_at (__p, std::forward<_Args>(__args)...);
321
315
}
322
316
323
- template <class _Tp , __enable_if_t <__has_destroy <allocator_type, _Tp*>::value , int > = 0 >
317
+ template <class _Tp , __enable_if_t <__has_destroy_v <allocator_type, _Tp*>, int > = 0 >
324
318
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type& __a, _Tp* __p) {
325
319
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
326
320
__a.destroy (__p);
327
321
_LIBCPP_SUPPRESS_DEPRECATED_POP
328
322
}
329
- template <class _Tp , class = void , __enable_if_t <!__has_destroy <allocator_type, _Tp*>::value , int > = 0 >
323
+ template <class _Tp , __enable_if_t <!__has_destroy_v <allocator_type, _Tp*>, int > = 0 >
330
324
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type&, _Tp* __p) {
331
325
std::__destroy_at (__p);
332
326
}
333
327
334
- template <class _Ap = _Alloc, __enable_if_t <__has_max_size <const _Ap>::value , int > = 0 >
328
+ template <class _Ap = _Alloc, __enable_if_t <__has_max_size_v <const _Ap>, int > = 0 >
335
329
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type& __a) _NOEXCEPT {
336
330
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
337
331
return __a.max_size ();
338
332
_LIBCPP_SUPPRESS_DEPRECATED_POP
339
333
}
340
- template <class _Ap = _Alloc, class = void , __enable_if_t <!__has_max_size <const _Ap>::value , int > = 0 >
334
+ template <class _Ap = _Alloc, __enable_if_t <!__has_max_size_v <const _Ap>, int > = 0 >
341
335
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type&) _NOEXCEPT {
342
336
return numeric_limits<size_type>::max () / sizeof (value_type);
343
337
}
344
338
345
- template <class _Ap = _Alloc, __enable_if_t <__has_select_on_container_copy_construction <const _Ap>::value , int > = 0 >
339
+ template <class _Ap = _Alloc, __enable_if_t <__has_select_on_container_copy_construction_v <const _Ap>, int > = 0 >
346
340
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
347
341
select_on_container_copy_construction (const allocator_type& __a) {
348
342
return __a.select_on_container_copy_construction ();
349
343
}
350
- template <class _Ap = _Alloc,
351
- class = void ,
352
- __enable_if_t <!__has_select_on_container_copy_construction<const _Ap>::value, int > = 0 >
344
+ template <class _Ap = _Alloc, __enable_if_t <!__has_select_on_container_copy_construction_v<const _Ap>, int > = 0 >
353
345
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
354
346
select_on_container_copy_construction (const allocator_type& __a) {
355
347
return __a;
@@ -372,40 +364,27 @@ struct __check_valid_allocator : true_type {
372
364
" original allocator" );
373
365
};
374
366
375
- // __is_default_allocator
367
+ // __is_default_allocator_v
376
368
template <class _Tp >
377
- struct __is_default_allocator : false_type {};
378
-
379
- template <class >
380
- class allocator ;
369
+ inline const bool __is_std_allocator_v = false ;
381
370
382
371
template <class _Tp >
383
- struct __is_default_allocator <allocator<_Tp> > : true_type {};
384
-
385
- // __is_cpp17_move_insertable
386
- template <class _Alloc , class = void >
387
- struct __is_cpp17_move_insertable : is_move_constructible<typename _Alloc::value_type> {};
372
+ inline const bool __is_std_allocator_v<allocator<_Tp> > = true ;
388
373
374
+ // __is_cpp17_move_insertable_v
389
375
template <class _Alloc >
390
- struct __is_cpp17_move_insertable <
391
- _Alloc,
392
- __enable_if_t < !__is_default_allocator<_Alloc>::value &&
393
- __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value > >
394
- : true_type {};
395
-
396
- // __is_cpp17_copy_insertable
397
- template <class _Alloc , class = void >
398
- struct __is_cpp17_copy_insertable
399
- : integral_constant<bool ,
400
- is_copy_constructible<typename _Alloc::value_type>::value &&
401
- __is_cpp17_move_insertable<_Alloc>::value > {};
376
+ inline const bool __is_cpp17_move_insertable_v =
377
+ is_move_constructible<typename _Alloc::value_type>::value ||
378
+ (!__is_std_allocator_v<_Alloc> &&
379
+ __has_construct_v<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>);
402
380
381
+ // __is_cpp17_copy_insertable_v
403
382
template <class _Alloc >
404
- struct __is_cpp17_copy_insertable <
405
- _Alloc,
406
- __enable_if_t < !__is_default_allocator< _Alloc>::value &&
407
- __has_construct <_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > >
408
- : __is_cpp17_move_insertable <_Alloc> {} ;
383
+ inline const bool __is_cpp17_copy_insertable_v =
384
+ __is_cpp17_move_insertable_v< _Alloc> &&
385
+ (is_copy_constructible< typename _Alloc::value_type >::value ||
386
+ (!__is_std_allocator_v <_Alloc> &&
387
+ __has_construct_v <_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>)) ;
409
388
410
389
#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
411
390
0 commit comments