@@ -149,13 +149,13 @@ using __is_always_equal _LIBCPP_NODEBUG =
149149// __allocator_traits_rebind
150150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
151151template <class _Tp , class _Up , class = void >
152- struct __has_rebind_other : false_type {} ;
152+ inline const bool __has_rebind_other_v = false ;
153153template <class _Tp , class _Up >
154- struct __has_rebind_other <_Tp, _Up, __void_t <typename _Tp::template rebind<_Up>::other> > : true_type {} ;
154+ inline const bool __has_rebind_other_v <_Tp, _Up, __void_t <typename _Tp::template rebind<_Up>::other> > = true ;
155155
156- template <class _Tp , class _Up , bool = __has_rebind_other <_Tp, _Up>::value >
156+ template <class _Tp , class _Up , bool = __has_rebind_other_v <_Tp, _Up> >
157157struct __allocator_traits_rebind {
158- static_assert (__has_rebind_other <_Tp, _Up>::value , " This allocator has to implement rebind" );
158+ static_assert (__has_rebind_other_v <_Tp, _Up>, " This allocator has to implement rebind" );
159159 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
160160};
161161template <template <class , class ...> class _Alloc , class _Tp , class ... _Args, class _Up >
@@ -173,53 +173,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_
173173
174174_LIBCPP_SUPPRESS_DEPRECATED_PUSH
175175
176- // __has_allocate_hint
176+ // __has_allocate_hint_v
177177template <class _Alloc , class _SizeType , class _ConstVoidPtr , class = void >
178- struct __has_allocate_hint : false_type {} ;
178+ inline const bool __has_allocate_hint_v = false ;
179179
180180template <class _Alloc , class _SizeType , class _ConstVoidPtr >
181- struct __has_allocate_hint <
181+ inline const bool __has_allocate_hint_v <
182182 _Alloc,
183183 _SizeType,
184184 _ConstVoidPtr,
185- decltype ((void )std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))>
186- : true_type {};
185+ decltype ((void )std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))> = true;
187186
188- // __has_construct
187+ // __has_construct_v
189188template <class , class _Alloc , class ... _Args>
190- struct __has_construct_impl : false_type {} ;
189+ inline const bool __has_construct_impl = false ;
191190
192191template <class _Alloc , class ... _Args>
193- struct __has_construct_impl < decltype (( void )std::declval<_Alloc>().construct(std::declval<_Args>()...)),
194- _Alloc,
195- _Args...> : true_type {} ;
192+ inline const bool
193+ __has_construct_impl< decltype (( void )std::declval<_Alloc>().construct(std::declval<_Args>()...)), _Alloc, _Args...> =
194+ true ;
196195
197196template <class _Alloc , class ... _Args>
198- struct __has_construct : __has_construct_impl<void , _Alloc, _Args...> {} ;
197+ inline const bool __has_construct_v = __has_construct_impl<void , _Alloc, _Args...>;
199198
200- // __has_destroy
199+ // __has_destroy_v
201200template <class _Alloc , class _Pointer , class = void >
202- struct __has_destroy : false_type {} ;
201+ inline const bool __has_destroy_v = false ;
203202
204203template <class _Alloc , class _Pointer >
205- struct __has_destroy <_Alloc, _Pointer, decltype (( void )std::declval<_Alloc>().destroy(std::declval<_Pointer>()))>
206- : true_type {} ;
204+ inline const bool
205+ __has_destroy_v<_Alloc, _Pointer, decltype (( void )std::declval<_Alloc>().destroy(std::declval<_Pointer>()))> = true ;
207206
208- // __has_max_size
207+ // __has_max_size_v
209208template <class _Alloc , class = void >
210- struct __has_max_size : false_type {} ;
209+ inline const bool __has_max_size_v = false ;
211210
212211template <class _Alloc >
213- struct __has_max_size <_Alloc, decltype ((void )std::declval<_Alloc&>().max_size())> : true_type {} ;
212+ inline const bool __has_max_size_v <_Alloc, decltype ((void )std::declval<_Alloc&>().max_size())> = true ;
214213
215- // __has_select_on_container_copy_construction
214+ // __has_select_on_container_copy_construction_v
216215template <class _Alloc , class = void >
217- struct __has_select_on_container_copy_construction : false_type {} ;
216+ inline const bool __has_select_on_container_copy_construction_v = false ;
218217
219218template <class _Alloc >
220- struct __has_select_on_container_copy_construction <
219+ inline const bool __has_select_on_container_copy_construction_v <
221220 _Alloc,
222- decltype ((void )std::declval<_Alloc>().select_on_container_copy_construction())> : true_type {} ;
221+ decltype ((void )std::declval<_Alloc>().select_on_container_copy_construction())> = true ;
223222
224223_LIBCPP_SUPPRESS_DEPRECATED_POP
225224
@@ -270,16 +269,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
270269 return __a.allocate (__n);
271270 }
272271
273- template <class _Ap = _Alloc, __enable_if_t <__has_allocate_hint <_Ap, size_type, const_void_pointer>::value , int > = 0 >
272+ template <class _Ap = _Alloc, __enable_if_t <__has_allocate_hint_v <_Ap, size_type, const_void_pointer>, int > = 0 >
274273 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
275274 allocate (allocator_type& __a, size_type __n, const_void_pointer __hint) {
276275 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
277276 return __a.allocate (__n, __hint);
278277 _LIBCPP_SUPPRESS_DEPRECATED_POP
279278 }
280- template <class _Ap = _Alloc,
281- class = void ,
282- __enable_if_t <!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int > = 0 >
279+ template <class _Ap = _Alloc, __enable_if_t <!__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int > = 0 >
283280 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
284281 allocate (allocator_type& __a, size_type __n, const_void_pointer) {
285282 return __a.allocate (__n);
@@ -302,52 +299,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
302299 __a.deallocate (__p, __n);
303300 }
304301
305- template <class _Tp , class ... _Args, __enable_if_t <__has_construct <allocator_type, _Tp*, _Args...>::value , int > = 0 >
302+ template <class _Tp , class ... _Args, __enable_if_t <__has_construct_v <allocator_type, _Tp*, _Args...>, int > = 0 >
306303 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
307304 construct (allocator_type& __a, _Tp* __p, _Args&&... __args) {
308305 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
309306 __a.construct (__p, std::forward<_Args>(__args)...);
310307 _LIBCPP_SUPPRESS_DEPRECATED_POP
311308 }
312- template <class _Tp ,
313- class ... _Args,
314- class = void ,
315- __enable_if_t <!__has_construct<allocator_type, _Tp*, _Args...>::value, int > = 0 >
309+ template <class _Tp , class ... _Args, __enable_if_t <!__has_construct_v<allocator_type, _Tp*, _Args...>, int > = 0 >
316310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
317311 construct (allocator_type&, _Tp* __p, _Args&&... __args) {
318312 std::__construct_at (__p, std::forward<_Args>(__args)...);
319313 }
320314
321- template <class _Tp , __enable_if_t <__has_destroy <allocator_type, _Tp*>::value , int > = 0 >
315+ template <class _Tp , __enable_if_t <__has_destroy_v <allocator_type, _Tp*>, int > = 0 >
322316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type& __a, _Tp* __p) {
323317 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
324318 __a.destroy (__p);
325319 _LIBCPP_SUPPRESS_DEPRECATED_POP
326320 }
327- template <class _Tp , class = void , __enable_if_t <!__has_destroy <allocator_type, _Tp*>::value , int > = 0 >
321+ template <class _Tp , __enable_if_t <!__has_destroy_v <allocator_type, _Tp*>, int > = 0 >
328322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy (allocator_type&, _Tp* __p) {
329323 std::__destroy_at (__p);
330324 }
331325
332- template <class _Ap = _Alloc, __enable_if_t <__has_max_size <const _Ap>::value , int > = 0 >
326+ template <class _Ap = _Alloc, __enable_if_t <__has_max_size_v <const _Ap>, int > = 0 >
333327 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type& __a) _NOEXCEPT {
334328 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
335329 return __a.max_size ();
336330 _LIBCPP_SUPPRESS_DEPRECATED_POP
337331 }
338- template <class _Ap = _Alloc, class = void , __enable_if_t <!__has_max_size <const _Ap>::value , int > = 0 >
332+ template <class _Ap = _Alloc, __enable_if_t <!__has_max_size_v <const _Ap>, int > = 0 >
339333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size (const allocator_type&) _NOEXCEPT {
340334 return numeric_limits<size_type>::max () / sizeof (value_type);
341335 }
342336
343- template <class _Ap = _Alloc, __enable_if_t <__has_select_on_container_copy_construction <const _Ap>::value , int > = 0 >
337+ template <class _Ap = _Alloc, __enable_if_t <__has_select_on_container_copy_construction_v <const _Ap>, int > = 0 >
344338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
345339 select_on_container_copy_construction (const allocator_type& __a) {
346340 return __a.select_on_container_copy_construction ();
347341 }
348- template <class _Ap = _Alloc,
349- class = void ,
350- __enable_if_t <!__has_select_on_container_copy_construction<const _Ap>::value, int > = 0 >
342+ template <class _Ap = _Alloc, __enable_if_t <!__has_select_on_container_copy_construction_v<const _Ap>, int > = 0 >
351343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
352344 select_on_container_copy_construction (const allocator_type& __a) {
353345 return __a;
@@ -370,40 +362,27 @@ struct __check_valid_allocator : true_type {
370362 " original allocator" );
371363};
372364
373- // __is_default_allocator
365+ // __is_default_allocator_v
374366template <class _Tp >
375- struct __is_default_allocator : false_type {};
376-
377- template <class >
378- class allocator ;
367+ inline const bool __is_std_allocator_v = false ;
379368
380369template <class _Tp >
381- struct __is_default_allocator <allocator<_Tp> > : true_type {};
382-
383- // __is_cpp17_move_insertable
384- template <class _Alloc , class = void >
385- struct __is_cpp17_move_insertable : is_move_constructible<typename _Alloc::value_type> {};
370+ inline const bool __is_std_allocator_v<allocator<_Tp> > = true ;
386371
372+ // __is_cpp17_move_insertable_v
387373template <class _Alloc >
388- struct __is_cpp17_move_insertable <
389- _Alloc,
390- __enable_if_t < !__is_default_allocator<_Alloc>::value &&
391- __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value > >
392- : true_type {};
393-
394- // __is_cpp17_copy_insertable
395- template <class _Alloc , class = void >
396- struct __is_cpp17_copy_insertable
397- : integral_constant<bool ,
398- is_copy_constructible<typename _Alloc::value_type>::value &&
399- __is_cpp17_move_insertable<_Alloc>::value > {};
374+ inline const bool __is_cpp17_move_insertable_v =
375+ is_move_constructible<typename _Alloc::value_type>::value ||
376+ (!__is_std_allocator_v<_Alloc> &&
377+ __has_construct_v<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>);
400378
379+ // __is_cpp17_copy_insertable_v
401380template <class _Alloc >
402- struct __is_cpp17_copy_insertable <
403- _Alloc,
404- __enable_if_t < !__is_default_allocator< _Alloc>::value &&
405- __has_construct <_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > >
406- : __is_cpp17_move_insertable <_Alloc> {} ;
381+ inline const bool __is_cpp17_copy_insertable_v =
382+ __is_cpp17_move_insertable_v< _Alloc> &&
383+ (is_copy_constructible< typename _Alloc::value_type >::value ||
384+ (!__is_std_allocator_v <_Alloc> &&
385+ __has_construct_v <_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>)) ;
407386
408387#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
409388
0 commit comments