@@ -84,10 +84,8 @@ namespace std {
84
84
# include < __cxx03/__config>
85
85
#else
86
86
# include < __config>
87
- # include < __memory/allocator.h>
88
- # include < __memory/allocator_destructor.h>
89
- # include < __memory/allocator_traits.h>
90
- # include < __memory/unique_ptr.h>
87
+ # include < __memory/construct_at.h>
88
+ # include < __new/allocate.h>
91
89
# include < __type_traits/add_cv_quals.h>
92
90
# include < __type_traits/add_pointer.h>
93
91
# include < __type_traits/aligned_storage.h>
@@ -103,6 +101,7 @@ namespace std {
103
101
# include < __type_traits/remove_cv.h>
104
102
# include < __type_traits/remove_cvref.h>
105
103
# include < __type_traits/remove_reference.h>
104
+ # include < __utility/exception_guard.h>
106
105
# include < __utility/forward.h>
107
106
# include < __utility/in_place.h>
108
107
# include < __utility/move.h>
@@ -339,22 +338,14 @@ struct _SmallHandler {
339
338
340
339
template <class ... _Args>
341
340
_LIBCPP_HIDE_FROM_ABI static _Tp& __create (any& __dest, _Args&&... __args) {
342
- typedef allocator<_Tp> _Alloc;
343
- typedef allocator_traits<_Alloc> _ATraits;
344
- _Alloc __a;
345
- _Tp* __ret = static_cast <_Tp*>(static_cast <void *>(&__dest.__s_ .__buf ));
346
- _ATraits::construct (__a, __ret, std::forward<_Args>(__args)...);
341
+ auto __ret = std::__construct_at (reinterpret_cast <_Tp*>(&__dest.__s_ .__buf ), std::forward<_Args>(__args)...);
347
342
__dest.__h_ = &_SmallHandler::__handle;
348
343
return *__ret;
349
344
}
350
345
351
346
private:
352
347
_LIBCPP_HIDE_FROM_ABI static void __destroy (any& __this) {
353
- typedef allocator<_Tp> _Alloc;
354
- typedef allocator_traits<_Alloc> _ATraits;
355
- _Alloc __a;
356
- _Tp* __p = static_cast <_Tp*>(static_cast <void *>(&__this.__s_ .__buf ));
357
- _ATraits::destroy (__a, __p);
348
+ std::__destroy_at (reinterpret_cast <_Tp*>(&__this.__s_ .__buf ));
358
349
__this.__h_ = nullptr ;
359
350
}
360
351
@@ -406,26 +397,20 @@ struct _LargeHandler {
406
397
407
398
template <class ... _Args>
408
399
_LIBCPP_HIDE_FROM_ABI static _Tp& __create (any& __dest, _Args&&... __args) {
409
- typedef allocator<_Tp> _Alloc;
410
- typedef allocator_traits<_Alloc> _ATraits;
411
- typedef __allocator_destructor<_Alloc> _Dp;
412
- _Alloc __a;
413
- unique_ptr<_Tp, _Dp> __hold (_ATraits::allocate (__a, 1 ), _Dp (__a, 1 ));
414
- _Tp* __ret = __hold.get ();
415
- _ATraits::construct (__a, __ret, std::forward<_Args>(__args)...);
416
- __dest.__s_ .__ptr = __hold.release ();
400
+ _Tp* __ptr = static_cast <_Tp*>(std::__libcpp_allocate<_Tp>(__element_count (1 )));
401
+ std::__exception_guard __guard ([&] { std::__libcpp_deallocate<_Tp>(__ptr, __element_count (1 )); });
402
+ std::__construct_at (__ptr, std::forward<_Args>(__args)...);
403
+ __guard.__complete ();
404
+ __dest.__s_ .__ptr = __ptr;
417
405
__dest.__h_ = &_LargeHandler::__handle;
418
- return *__ret ;
406
+ return *__ptr ;
419
407
}
420
408
421
409
private:
422
410
_LIBCPP_HIDE_FROM_ABI static void __destroy (any& __this) {
423
- typedef allocator<_Tp> _Alloc;
424
- typedef allocator_traits<_Alloc> _ATraits;
425
- _Alloc __a;
426
411
_Tp* __p = static_cast <_Tp*>(__this.__s_ .__ptr );
427
- _ATraits::destroy (__a, __p);
428
- _ATraits::deallocate (__a, __p, 1 );
412
+ std::__destroy_at ( __p);
413
+ std::__libcpp_deallocate<_Tp>( __p, __element_count ( 1 ) );
429
414
__this.__h_ = nullptr ;
430
415
}
431
416
@@ -613,6 +598,11 @@ _LIBCPP_POP_MACROS
613
598
# include < type_traits>
614
599
# include < variant>
615
600
# endif
601
+
602
+ # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
603
+ # include < cstring>
604
+ # include < limits>
605
+ # endif
616
606
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
617
607
618
608
#endif // _LIBCPP_ANY
0 commit comments