@@ -84,10 +84,8 @@ namespace std {
8484# include < __cxx03/__config>
8585#else
8686# 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>
9189# include < __type_traits/add_cv_quals.h>
9290# include < __type_traits/add_pointer.h>
9391# include < __type_traits/aligned_storage.h>
@@ -103,6 +101,7 @@ namespace std {
103101# include < __type_traits/remove_cv.h>
104102# include < __type_traits/remove_cvref.h>
105103# include < __type_traits/remove_reference.h>
104+ # include < __utility/exception_guard.h>
106105# include < __utility/forward.h>
107106# include < __utility/in_place.h>
108107# include < __utility/move.h>
@@ -339,22 +338,14 @@ struct _SmallHandler {
339338
340339 template <class ... _Args>
341340 _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)...);
347342 __dest.__h_ = &_SmallHandler::__handle;
348343 return *__ret;
349344 }
350345
351346private:
352347 _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 ));
358349 __this.__h_ = nullptr ;
359350 }
360351
@@ -406,26 +397,20 @@ struct _LargeHandler {
406397
407398 template <class ... _Args>
408399 _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;
417405 __dest.__h_ = &_LargeHandler::__handle;
418- return *__ret ;
406+ return *__ptr ;
419407 }
420408
421409private:
422410 _LIBCPP_HIDE_FROM_ABI static void __destroy (any& __this) {
423- typedef allocator<_Tp> _Alloc;
424- typedef allocator_traits<_Alloc> _ATraits;
425- _Alloc __a;
426411 _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 ) );
429414 __this.__h_ = nullptr ;
430415 }
431416
@@ -613,6 +598,11 @@ _LIBCPP_POP_MACROS
613598# include < type_traits>
614599# include < variant>
615600# endif
601+
602+ # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
603+ # include < cstring>
604+ # include < limits>
605+ # endif
616606#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
617607
618608#endif // _LIBCPP_ANY
0 commit comments