@@ -151,13 +151,13 @@ using __is_always_equal _LIBCPP_NODEBUG =
151151
152152// __allocator_traits_rebind
153153template <class _Tp , class _Up , class = void >
154- struct __has_rebind_other : false_type {} ;
154+ inline const bool __has_rebind_other_v = false ;
155155template <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 ;
157157
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> >
159159struct __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" );
161161 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
162162};
163163template <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_
175175
176176_LIBCPP_SUPPRESS_DEPRECATED_PUSH
177177
178- // __has_allocate_hint
178+ // __has_allocate_hint_v
179179template <class _Alloc , class _SizeType , class _ConstVoidPtr , class = void >
180- struct __has_allocate_hint : false_type {} ;
180+ inline const bool __has_allocate_hint_v = false ;
181181
182182template <class _Alloc , class _SizeType , class _ConstVoidPtr >
183- struct __has_allocate_hint <
183+ inline const bool __has_allocate_hint_v <
184184 _Alloc,
185185 _SizeType,
186186 _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;
189188
190- // __has_construct
189+ // __has_construct_v
191190template <class , class _Alloc , class ... _Args>
192- struct __has_construct_impl : false_type {} ;
191+ inline const bool __has_construct_impl = false ;
193192
194193template <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 ;
198197
199198template <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...>;
201200
202- // __has_destroy
201+ // __has_destroy_v
203202template <class _Alloc , class _Pointer , class = void >
204- struct __has_destroy : false_type {} ;
203+ inline const bool __has_destroy_v = false ;
205204
206205template <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 ;
209208
210- // __has_max_size
209+ // __has_max_size_v
211210template <class _Alloc , class = void >
212- struct __has_max_size : false_type {} ;
211+ inline const bool __has_max_size_v = false ;
213212
214213template <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 ;
216215
217- // __has_select_on_container_copy_construction
216+ // __has_select_on_container_copy_construction_v
218217template <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 ;
220219
221220template <class _Alloc >
222- struct __has_select_on_container_copy_construction <
221+ inline const bool __has_select_on_container_copy_construction_v <
223222 _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 ;
225224
226225_LIBCPP_SUPPRESS_DEPRECATED_POP
227226
@@ -272,16 +271,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
272271 return __a.allocate (__n);
273272 }
274273
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 >
276275 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
277276 allocate (allocator_type& __a, size_type __n, const_void_pointer __hint) {
278277 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
279278 return __a.allocate (__n, __hint);
280279 _LIBCPP_SUPPRESS_DEPRECATED_POP
281280 }
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 >
285282 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
286283 allocate (allocator_type& __a, size_type __n, const_void_pointer) {
287284 return __a.allocate (__n);
@@ -304,52 +301,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
304301 __a.deallocate (__p, __n);
305302 }
306303
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 >
308305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
309306 construct (allocator_type& __a, _Tp* __p, _Args&&... __args) {
310307 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
311308 __a.construct (__p, std::forward<_Args>(__args)...);
312309 _LIBCPP_SUPPRESS_DEPRECATED_POP
313310 }
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 >
318312 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
319313 construct (allocator_type&, _Tp* __p, _Args&&... __args) {
320314 std::__construct_at (__p, std::forward<_Args>(__args)...);
321315 }
322316
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 >
324318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type& __a, _Tp* __p) {
325319 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
326320 __a.destroy (__p);
327321 _LIBCPP_SUPPRESS_DEPRECATED_POP
328322 }
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 >
330324 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type&, _Tp* __p) {
331325 std::__destroy_at (__p);
332326 }
333327
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 >
335329 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type& __a) _NOEXCEPT {
336330 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
337331 return __a.max_size ();
338332 _LIBCPP_SUPPRESS_DEPRECATED_POP
339333 }
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 >
341335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type&) _NOEXCEPT {
342336 return numeric_limits<size_type>::max () / sizeof (value_type);
343337 }
344338
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 >
346340 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
347341 select_on_container_copy_construction (const allocator_type& __a) {
348342 return __a.select_on_container_copy_construction ();
349343 }
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 >
353345 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
354346 select_on_container_copy_construction (const allocator_type& __a) {
355347 return __a;
@@ -372,40 +364,27 @@ struct __check_valid_allocator : true_type {
372364 " original allocator" );
373365};
374366
375- // __is_default_allocator
367+ // __is_default_allocator_v
376368template <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 ;
381370
382371template <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 ;
388373
374+ // __is_cpp17_move_insertable_v
389375template <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&&>);
402380
381+ // __is_cpp17_copy_insertable_v
403382template <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&>)) ;
409388
410389#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
411390
0 commit comments