diff options
author | hiddenpath <hiddenpath@yandex-team.com> | 2024-02-21 23:16:42 +0300 |
---|---|---|
committer | hiddenpath <hiddenpath@yandex-team.com> | 2024-02-21 23:33:25 +0300 |
commit | 9052eb5cc304b8da8885fc4e3364ebddc16945f3 (patch) | |
tree | 3c252f6161dd0745c7732d74c9304c000645ab47 /contrib/libs/cxxsupp/libcxx/include/__memory | |
parent | f5eb715f103692e7c7536e13bef3f281fd78e5e7 (diff) | |
download | ydb-9052eb5cc304b8da8885fc4e3364ebddc16945f3.tar.gz |
Update libcxx to llvmorg-17.0.6
Update libcxx to llvmorg-17.0.6
c871ef572c71b4fef22d4a9e65bcebc57e625aea
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__memory')
23 files changed, 409 insertions, 186 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/align.h b/contrib/libs/cxxsupp/libcxx/include/__memory/align.h index c6792206b0..bbb995f4a8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/align.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/align.h @@ -18,7 +18,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); +_LIBCPP_EXPORTED_FROM_ABI void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/aligned_alloc.h b/contrib/libs/cxxsupp/libcxx/include/__memory/aligned_alloc.h new file mode 100644 index 0000000000..bdcd5089a0 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/aligned_alloc.h @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_ALIGNED_ALLOC_H +#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H + +#include <__config> +#include <cstddef> +#include <cstdlib> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION + +// Low-level helpers to call the aligned allocation and deallocation functions +// on the target platform. This is used to implement libc++'s own memory +// allocation routines -- if you need to allocate memory inside the library, +// chances are that you want to use `__libcpp_allocate` instead. +// +// Returns the allocated memory, or `nullptr` on failure. +inline _LIBCPP_HIDE_FROM_ABI +void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { +# if defined(_LIBCPP_MSVCRT_LIKE) + return ::_aligned_malloc(__size, __alignment); +// Use posix_memalign instead of ::aligned_alloc to fix the musl and some of the tests +# elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC) && false + // aligned_alloc() requires that __size is a multiple of __alignment, + // but for C++ [new.delete.general], only states "if the value of an + // alignment argument passed to any of these functions is not a valid + // alignment value, the behavior is undefined". + // To handle calls such as ::operator new(1, std::align_val_t(128)), we + // round __size up to the next multiple of __alignment. + size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1); + // Rounding up could have wrapped around to zero, so we have to add another + // max() ternary to the actual call site to avoid succeeded in that case. + return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size); +# else + void* __result = nullptr; + (void)::posix_memalign(&__result, __alignment, __size); + // If posix_memalign fails, __result is unmodified so we still return `nullptr`. + return __result; +# endif +} + +inline _LIBCPP_HIDE_FROM_ABI +void __libcpp_aligned_free(void* __ptr) { +#if defined(_LIBCPP_MSVCRT_LIKE) + ::_aligned_free(__ptr); +#else + ::free(__ptr); +#endif +} + +#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MEMORY_ALIGNED_ALLOC_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h index ef205f855c..8d8ad071e2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocate_at_least.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 20 +#if _LIBCPP_STD_VER >= 23 template <class _Pointer> struct allocation_result { _Pointer ptr; @@ -55,7 +55,7 @@ __allocation_result<typename allocator_traits<_Alloc>::pointer> __allocate_at_le return {__alloc.allocate(__n), __n}; } -#endif // _LIBCPP_STD_VER > 20 +#endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocation_guard.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocation_guard.h index 424598cc81..f63b17430e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocation_guard.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocation_guard.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_ALLOCATION_GUARD_H #include <__config> +#include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__utility/move.h> #include <cstddef> @@ -19,6 +20,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // Helper class to allocate memory using an Allocator in an exception safe @@ -55,9 +59,29 @@ struct __allocation_guard { _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { - if (__ptr_ != nullptr) { - allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_); + __destroy(); + } + + _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete; + _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT + : __alloc_(std::move(__other.__alloc_)) + , __n_(__other.__n_) + , __ptr_(__other.__ptr_) { + __other.__ptr_ = nullptr; + } + + _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete; + _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT { + if (std::addressof(__other) != this) { + __destroy(); + + __alloc_ = std::move(__other.__alloc_); + __n_ = __other.__n_; + __ptr_ = __other.__ptr_; + __other.__ptr_ = nullptr; } + + return *this; } _LIBCPP_HIDE_FROM_ABI @@ -73,6 +97,13 @@ struct __allocation_guard { } private: + _LIBCPP_HIDE_FROM_ABI + void __destroy() _NOEXCEPT { + if (__ptr_ != nullptr) { + allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_); + } + } + _Alloc __alloc_; _Size __n_; _Pointer __ptr_; @@ -80,4 +111,6 @@ private: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h index 54c9b78d52..47e1ef926a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h @@ -11,6 +11,7 @@ #define _LIBCPP___MEMORY_ALLOCATOR_H #include <__config> +#include <__memory/addressof.h> #include <__memory/allocate_at_least.h> #include <__memory/allocator_traits.h> #include <__type_traits/is_constant_evaluated.h> @@ -20,7 +21,6 @@ #include <__utility/forward.h> #include <cstddef> #include <new> -#include <stdexcept> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -98,8 +98,7 @@ public: typedef true_type propagate_on_container_move_assignment; typedef true_type is_always_equal; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - allocator() _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -116,7 +115,7 @@ public: } } -#if _LIBCPP_STD_VER > 20 +#if _LIBCPP_STD_VER >= 23 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) { return {allocate(__n), __n}; @@ -187,8 +186,7 @@ public: typedef true_type propagate_on_container_move_assignment; typedef true_type is_always_equal; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - allocator() _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 @@ -205,7 +203,7 @@ public: } } -#if _LIBCPP_STD_VER > 20 +#if _LIBCPP_STD_VER >= 23 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { return {allocate(__n), __n}; @@ -264,10 +262,14 @@ template <class _Tp, class _Up> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} +#if _LIBCPP_STD_VER <= 17 + template <class _Tp, class _Up> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___MEMORY_ALLOCATOR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_arg_t.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_arg_t.h index 15f8c98c4c..4d9c115f72 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_arg_t.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_arg_t.h @@ -25,10 +25,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; }; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; -#else -/* inline */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#if _LIBCPP_STD_VER >= 17 +inline constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#elif !defined(_LIBCPP_CXX03_LANG) +constexpr allocator_arg_t allocator_arg = allocator_arg_t(); #endif #ifndef _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h index 3a23b47c74..4658098d64 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h @@ -300,7 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 static void construct(allocator_type&, _Tp* __p, _Args&&... __args) { -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...); #else ::new ((void*)__p) _Tp(_VSTD::forward<_Args>(__args)...); @@ -319,7 +319,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) { -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 _VSTD::destroy_at(__p); #else __p->~_Tp(); @@ -401,6 +401,25 @@ struct __is_cpp17_copy_insertable<_Alloc, __enable_if_t< : __is_cpp17_move_insertable<_Alloc> { }; +// ASan choices +#ifndef _LIBCPP_HAS_NO_ASAN +# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 +#endif + +#ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS +template <class _Alloc> +struct __asan_annotate_container_with_allocator +# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1600 + : true_type {}; +# else + // TODO(LLVM-18): Remove the special-casing + : false_type {}; +# endif + +template <class _Tp> +struct __asan_annotate_container_with_allocator<allocator<_Tp> > : true_type {}; +#endif + #undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h index a1fd2441f9..00c2928dcc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <size_t _Np, class _Tp> [[nodiscard]] @@ -34,12 +34,12 @@ constexpr _Tp* assume_aligned(_Tp* __ptr) { if (is_constant_evaluated()) { return __ptr; } else { - _LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated"); + _LIBCPP_ASSERT_UNCATEGORIZED(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated"); return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np)); } } -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/builtin_new_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/builtin_new_allocator.h index cd1a866ca6..ab449ad299 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/builtin_new_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/builtin_new_allocator.h @@ -28,10 +28,10 @@ struct __builtin_new_allocator { struct __builtin_new_deleter { typedef void* pointer_type; - _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align) : __size_(__size), __align_(__align) {} - void operator()(void* __p) const _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const _NOEXCEPT { _VSTD::__libcpp_deallocate(__p, __size_, __align_); } @@ -42,25 +42,25 @@ struct __builtin_new_allocator { typedef unique_ptr<void, __builtin_new_deleter> __holder_t; - static __holder_t __allocate_bytes(size_t __s, size_t __align) { + _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_bytes(size_t __s, size_t __align) { return __holder_t(_VSTD::__libcpp_allocate(__s, __align), __builtin_new_deleter(__s, __align)); } - static void __deallocate_bytes(void* __p, size_t __s, + _LIBCPP_HIDE_FROM_ABI static void __deallocate_bytes(void* __p, size_t __s, size_t __align) _NOEXCEPT { _VSTD::__libcpp_deallocate(__p, __s, __align); } template <class _Tp> _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE - static __holder_t __allocate_type(size_t __n) { + _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_type(size_t __n) { return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); } template <class _Tp> _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE - static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT { __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h b/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h index 8093d7c931..f24b2bac56 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/compressed_pair.h @@ -13,7 +13,7 @@ #include <__config> #include <__fwd/get.h> #include <__fwd/tuple.h> -#include <__tuple_dir/tuple_indices.h> +#include <__tuple/tuple_indices.h> #include <__type_traits/decay.h> #include <__type_traits/dependent_type.h> #include <__type_traits/enable_if.h> @@ -31,6 +31,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // Tag used to default initialize one or both of the pair's elements. @@ -46,7 +49,7 @@ struct __compressed_pair_elem { _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} - template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> > + template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_(std::forward<_Up>(__u)) {} @@ -75,7 +78,7 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} - template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> > + template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_type(std::forward<_Up>(__u)) {} @@ -174,4 +177,6 @@ void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__memory/concepts.h index 12d7bf85ed..97cc3583ec 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/concepts.h @@ -19,6 +19,7 @@ #include <__ranges/concepts.h> #include <__type_traits/is_reference.h> #include <__type_traits/remove_cvref.h> +#include <__type_traits/remove_reference.h> // TODO(modules): This should not be required #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -26,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 namespace ranges { @@ -62,7 +63,7 @@ concept __nothrow_forward_range = } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h b/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h index 14484dd6aa..a032c33b47 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h @@ -26,26 +26,29 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD // construct_at -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) { - _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"); - return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...); + _LIBCPP_ASSERT_UNCATEGORIZED(__location != nullptr, "null pointer given to construct_at"); + return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); } #endif template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) { -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 return std::construct_at(__location, std::forward<_Args>(__args)...); #else - return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"), + return _LIBCPP_ASSERT_UNCATEGORIZED(__location != nullptr, "null pointer given to construct_at"), ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); #endif } @@ -62,16 +65,16 @@ _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { - _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at"); + _LIBCPP_ASSERT_UNCATEGORIZED(__loc != nullptr, "null pointer given to destroy_at"); __loc->~_Tp(); } -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { - _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at"); - _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc)); + _LIBCPP_ASSERT_UNCATEGORIZED(__loc != nullptr, "null pointer given to destroy_at"); + std::__destroy(std::begin(*__loc), std::end(*__loc)); } #endif @@ -79,7 +82,7 @@ template <class _ForwardIterator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) { for (; __first != __last; ++__first) - _VSTD::__destroy_at(_VSTD::addressof(*__first)); + std::__destroy_at(std::addressof(*__first)); return __first; } @@ -93,38 +96,40 @@ _BidirectionalIterator __reverse_destroy(_BidirectionalIterator __first, _Bidire return __last; } -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { - _VSTD::__destroy_at(__loc); + std::__destroy_at(__loc); } -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) { - _VSTD::__destroy_at(__loc); + std::__destroy_at(__loc); } #endif template <class _ForwardIterator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) { - (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last)); + (void)std::__destroy(std::move(__first), std::move(__last)); } template <class _ForwardIterator, class _Size> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { for (; __n > 0; (void)++__first, --__n) - _VSTD::__destroy_at(_VSTD::addressof(*__first)); + std::__destroy_at(std::addressof(*__first)); return __first; } -#endif // _LIBCPP_STD_VER > 14 +#endif // _LIBCPP_STD_VER >= 17 _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h index c4f20def45..c33e7bd43f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h @@ -200,7 +200,7 @@ template <class _Pointer, class = __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value > > _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename decay<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>::type +__decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))> __to_address(const _Pointer& __p) _NOEXCEPT { return __to_address_helper<_Pointer>::__call(__p); } @@ -223,7 +223,7 @@ struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to } }; -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY constexpr auto to_address(_Tp *__p) noexcept { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h index e63585d1ab..ed800f4a75 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_construct_at.h @@ -13,7 +13,7 @@ #include <__concepts/destructible.h> #include <__config> #include <__iterator/incrementable_traits.h> -#include <__iterator/readable_traits.h> +#include <__iterator/iterator_traits.h> #include <__memory/concepts.h> #include <__memory/construct_at.h> #include <__ranges/access.h> @@ -28,9 +28,12 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 namespace ranges { // construct_at @@ -118,8 +121,10 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h index 15c78e20ba..01c3e01003 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/ranges_uninitialized_algorithms.h @@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 namespace ranges { @@ -45,7 +45,7 @@ struct __fn { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable<iter_value_t<_ForwardIterator>> - _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; return _VSTD::__uninitialized_default_construct<_ValueType>( _VSTD::move(__first), _VSTD::move(__last)); @@ -53,7 +53,7 @@ struct __fn { template <__nothrow_forward_range _ForwardRange> requires default_initializable<range_value_t<_ForwardRange>> - borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { + _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { return (*this)(ranges::begin(__range), ranges::end(__range)); } }; @@ -71,7 +71,7 @@ namespace __uninitialized_default_construct_n { struct __fn { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable<iter_value_t<_ForwardIterator>> - _ForwardIterator operator()(_ForwardIterator __first, + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; return _VSTD::__uninitialized_default_construct_n<_ValueType>(_VSTD::move(__first), __n); @@ -92,7 +92,7 @@ struct __fn { template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> requires default_initializable<iter_value_t<_ForwardIterator>> - _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; return _VSTD::__uninitialized_value_construct<_ValueType>( _VSTD::move(__first), _VSTD::move(__last)); @@ -100,7 +100,7 @@ struct __fn { template <__nothrow_forward_range _ForwardRange> requires default_initializable<range_value_t<_ForwardRange>> - borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { + _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { return (*this)(ranges::begin(__range), ranges::end(__range)); } }; @@ -118,7 +118,7 @@ namespace __uninitialized_value_construct_n { struct __fn { template <__nothrow_forward_iterator _ForwardIterator> requires default_initializable<iter_value_t<_ForwardIterator>> - _ForwardIterator operator()(_ForwardIterator __first, + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; return _VSTD::__uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n); @@ -140,14 +140,14 @@ struct __fn { __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp> requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> - _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; return _VSTD::__uninitialized_fill<_ValueType>(_VSTD::move(__first), _VSTD::move(__last), __x); } template <__nothrow_forward_range _ForwardRange, class _Tp> requires constructible_from<range_value_t<_ForwardRange>, const _Tp&> - borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range, const _Tp& __x) const { + _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range, const _Tp& __x) const { return (*this)(ranges::begin(__range), ranges::end(__range), __x); } }; @@ -165,7 +165,7 @@ namespace __uninitialized_fill_n { struct __fn { template <__nothrow_forward_iterator _ForwardIterator, class _Tp> requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> - _ForwardIterator operator()(_ForwardIterator __first, + _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n, const _Tp& __x) const { using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; @@ -192,7 +192,7 @@ struct __fn { __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel2> requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> - uninitialized_copy_result<_InputIterator, _OutputIterator> + _LIBCPP_HIDE_FROM_ABI uninitialized_copy_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const { using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; @@ -203,7 +203,7 @@ struct __fn { template <input_range _InputRange, __nothrow_forward_range _OutputRange> requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>> - uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> + _LIBCPP_HIDE_FROM_ABI uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> operator()( _InputRange&& __in_range, _OutputRange&& __out_range) const { return (*this)(ranges::begin(__in_range), ranges::end(__in_range), ranges::begin(__out_range), ranges::end(__out_range)); @@ -228,7 +228,7 @@ struct __fn { __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel> requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> - uninitialized_copy_n_result<_InputIterator, _OutputIterator> + _LIBCPP_HIDE_FROM_ABI uninitialized_copy_n_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n, _OutputIterator __ofirst, _Sentinel __olast) const { using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; @@ -257,7 +257,7 @@ struct __fn { __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel2> requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>> - uninitialized_move_result<_InputIterator, _OutputIterator> + _LIBCPP_HIDE_FROM_ABI uninitialized_move_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const { using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); }; @@ -268,7 +268,7 @@ struct __fn { template <input_range _InputRange, __nothrow_forward_range _OutputRange> requires constructible_from<range_value_t<_OutputRange>, range_rvalue_reference_t<_InputRange>> - uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> + _LIBCPP_HIDE_FROM_ABI uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const { return (*this)(ranges::begin(__in_range), ranges::end(__in_range), ranges::begin(__out_range), ranges::end(__out_range)); @@ -293,7 +293,7 @@ struct __fn { __nothrow_forward_iterator _OutputIterator, __nothrow_sentinel_for<_OutputIterator> _Sentinel> requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>> - uninitialized_move_n_result<_InputIterator, _OutputIterator> + _LIBCPP_HIDE_FROM_ABI uninitialized_move_n_result<_InputIterator, _OutputIterator> operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n, _OutputIterator __ofirst, _Sentinel __olast) const { using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; @@ -312,7 +312,7 @@ inline namespace __cpo { } // namespace ranges -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/raw_storage_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/raw_storage_iterator.h index 11971de0fa..df7ef5afe7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/raw_storage_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/raw_storage_iterator.h @@ -39,7 +39,7 @@ private: public: typedef output_iterator_tag iterator_category; typedef void value_type; -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 typedef ptrdiff_t difference_type; #else typedef void difference_type; diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h index 46c0534c3d..d8395dc735 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h @@ -29,11 +29,26 @@ #include <__memory/pointer_traits.h> #include <__memory/uninitialized_algorithms.h> #include <__memory/unique_ptr.h> +#include <__type_traits/add_lvalue_reference.h> +#include <__type_traits/conditional.h> +#include <__type_traits/conjunction.h> +#include <__type_traits/disjunction.h> +#include <__type_traits/is_array.h> +#include <__type_traits/is_bounded_array.h> +#include <__type_traits/is_convertible.h> +#include <__type_traits/is_move_constructible.h> +#include <__type_traits/is_reference.h> +#include <__type_traits/is_unbounded_array.h> +#include <__type_traits/nat.h> +#include <__type_traits/negation.h> +#include <__type_traits/remove_extent.h> +#include <__type_traits/remove_reference.h> +#include <__utility/declval.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/swap.h> +#include <__verbose_abort> #include <cstddef> -#include <cstdlib> // abort #include <iosfwd> #include <new> #include <stdexcept> @@ -105,12 +120,12 @@ __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT #endif } -class _LIBCPP_EXCEPTION_ABI bad_weak_ptr +class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception { public: - bad_weak_ptr() _NOEXCEPT = default; - bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; ~bad_weak_ptr() _NOEXCEPT override; const char* what() const _NOEXCEPT override; }; @@ -118,16 +133,16 @@ public: _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_bad_weak_ptr() { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_weak_ptr(); #else - _VSTD::abort(); + _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode"); #endif } template<class _Tp> class _LIBCPP_TEMPLATE_VIS weak_ptr; -class _LIBCPP_TYPE_VIS __shared_count +class _LIBCPP_EXPORTED_FROM_ABI __shared_count { __shared_count(const __shared_count&); __shared_count& operator=(const __shared_count&); @@ -183,7 +198,7 @@ public: } }; -class _LIBCPP_TYPE_VIS __shared_weak_count +class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count { #ifdef _LIBCPP_HAS_NO_THREADS @@ -246,12 +261,12 @@ public: : __data_(__compressed_pair<_Tp, _Dp>(__p, _VSTD::move(__d)), _VSTD::move(__a)) {} #ifndef _LIBCPP_HAS_NO_RTTI - const void* __get_deleter(const type_info&) const _NOEXCEPT override; + _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override; #endif private: - void __on_zero_shared() _NOEXCEPT override; - void __on_zero_shared_weak() _NOEXCEPT override; + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override; + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override; }; #ifndef _LIBCPP_HAS_NO_RTTI @@ -321,8 +336,8 @@ struct __shared_ptr_emplace _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); } private: - void __on_zero_shared() _NOEXCEPT override { -#if _LIBCPP_STD_VER > 17 + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { +#if _LIBCPP_STD_VER >= 20 if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) { __get_elem()->~_Tp(); } else { @@ -335,7 +350,7 @@ private: #endif } - void __on_zero_shared_weak() _NOEXCEPT override { + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override { using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type; using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer; _ControlBlockAlloc __tmp(*__get_alloc()); @@ -362,13 +377,13 @@ private: _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); } - _Alloc* __get_alloc() _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_); typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair); _Alloc *__alloc = reinterpret_cast<_Alloc*>(__first); return __alloc; } - _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT { _CompressedPair *__as_pair = reinterpret_cast<_CompressedPair*>(__blob_); typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair); _Tp *__elem = reinterpret_cast<_Tp*>(__second); @@ -459,10 +474,10 @@ struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : tru template <class _Dp, class _Pt, class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))> -static true_type __well_formed_deleter_test(int); +true_type __well_formed_deleter_test(int); template <class, class> -static false_type __well_formed_deleter_test(...); +false_type __well_formed_deleter_test(...); template <class _Dp, class _Pt> struct __well_formed_deleter : decltype(std::__well_formed_deleter_test<_Dp, _Pt>(0)) {}; @@ -476,7 +491,7 @@ struct __shared_ptr_deleter_ctor_reqs }; #if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI) -# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((trivial_abi)) +# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__)) #else # define _LIBCPP_SHARED_PTR_TRIVIAL_ABI #endif @@ -485,7 +500,7 @@ template<class _Tp> class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { public: -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 typedef weak_ptr<_Tp> weak_type; typedef remove_extent_t<_Tp> element_type; #else @@ -520,7 +535,7 @@ public: #endif >::value > > - explicit shared_ptr(_Yp* __p) : __ptr_(__p) { + _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT> _CntrlBlk; @@ -534,10 +549,10 @@ public: shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; #ifndef _LIBCPP_CXX03_LANG @@ -546,14 +561,14 @@ public: __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); #endif // not _LIBCPP_CXX03_LANG __enable_weak_this(__p, __p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> > @@ -561,10 +576,10 @@ public: shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; @@ -578,14 +593,14 @@ public: #endif // not _LIBCPP_CXX03_LANG __cntrl_ = _VSTD::addressof(*__hold2.release()); __enable_weak_this(__p, __p); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } template<class _Dp> @@ -593,10 +608,10 @@ public: shared_ptr(nullptr_t __p, _Dp __d) : __ptr_(nullptr) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk; #ifndef _LIBCPP_CXX03_LANG @@ -604,14 +619,14 @@ public: #else __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); #endif // not _LIBCPP_CXX03_LANG -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } template<class _Dp, class _Alloc> @@ -619,10 +634,10 @@ public: shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) : __ptr_(nullptr) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; @@ -635,14 +650,14 @@ public: _CntrlBlk(__p, __d, __a); #endif // not _LIBCPP_CXX03_LANG __cntrl_ = _VSTD::addressof(*__hold2.release()); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_NO_EXCEPTIONS } template<class _Yp> @@ -655,6 +670,18 @@ public: __cntrl_->__add_shared(); } +// LWG-2996 +// We don't backport because it is an evolutionary change. +#if _LIBCPP_STD_VER >= 20 + template <class _Yp> + _LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r, element_type* __p) noexcept + : __ptr_(__p), + __cntrl_(__r.__cntrl_) { + __r.__ptr_ = nullptr; + __r.__cntrl_ = nullptr; + } +#endif + _LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr& __r) _NOEXCEPT : __ptr_(__r.__ptr_), @@ -725,7 +752,7 @@ public: shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER >= 14 if (__ptr_ == nullptr) __cntrl_ = nullptr; else @@ -748,7 +775,7 @@ public: shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) { -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER >= 14 if (__ptr_ == nullptr) __cntrl_ = nullptr; else @@ -921,7 +948,7 @@ public: return __cntrl_ == __p.__cntrl_; } -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<element_type> operator[](ptrdiff_t __i) const { @@ -1001,7 +1028,7 @@ private: template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; }; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template<class _Tp> shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; template<class _Tp, class _Dp> @@ -1050,7 +1077,7 @@ shared_ptr<_Tp> make_shared_for_overwrite() #endif // _LIBCPP_STD_VER >= 20 -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <size_t _Alignment> struct __sp_aligned_storage { @@ -1110,7 +1137,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_ private: - void __on_zero_shared() _NOEXCEPT override { + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { #if _LIBCPP_STD_VER >= 20 if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) { std::__reverse_destroy(__data_, __data_ + __count_); @@ -1124,7 +1151,7 @@ private: #endif } - void __on_zero_shared_weak() _NOEXCEPT override { + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override { using _AlignedStorage = __sp_aligned_storage<alignof(__unbounded_array_control_block)>; using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>; using _PointerTraits = pointer_traits<typename allocator_traits<_StorageAlloc>::pointer>; @@ -1133,7 +1160,8 @@ private: __alloc_.~_Alloc(); size_t __size = __unbounded_array_control_block::__bytes_for(__count_); _AlignedStorage* __storage = reinterpret_cast<_AlignedStorage*>(this); - allocator_traits<_StorageAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*__storage), __size); + allocator_traits<_StorageAlloc>::deallocate( + __tmp, _PointerTraits::pointer_to(*__storage), __size / sizeof(_AlignedStorage)); } _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_; @@ -1196,7 +1224,7 @@ struct __bounded_array_control_block<_Tp[_Count], _Alloc> ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_ private: - void __on_zero_shared() _NOEXCEPT override { + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { #if _LIBCPP_STD_VER >= 20 if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) { std::__reverse_destroy(__data_, __data_ + _Count); @@ -1210,13 +1238,13 @@ private: #endif } - void __on_zero_shared_weak() _NOEXCEPT override { + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override { using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, __bounded_array_control_block>; using _PointerTraits = pointer_traits<typename allocator_traits<_ControlBlockAlloc>::pointer>; _ControlBlockAlloc __tmp(__alloc_); __alloc_.~_Alloc(); - allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*this), sizeof(*this)); + allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*this), 1); } _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_; @@ -1240,9 +1268,9 @@ shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ... return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block); } -#endif // _LIBCPP_STD_VER > 14 +#endif // _LIBCPP_STD_VER >= 17 -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 // bounded array variants template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>> @@ -1334,7 +1362,7 @@ shared_ptr<_Tp> make_shared_for_overwrite(size_t __n) return std::__allocate_shared_unbounded_array<_Tp>(allocator<__for_overwrite_tag>(), __n); } -#endif // _LIBCPP_STD_VER > 17 +#endif // _LIBCPP_STD_VER >= 20 template<class _Tp, class _Up> inline _LIBCPP_INLINE_VISIBILITY @@ -1394,7 +1422,7 @@ operator>=(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT #endif // _LIBCPP_STD_VER <= 17 -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template<class _Tp, class _Up> _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) noexcept @@ -1503,7 +1531,7 @@ operator>=(nullptr_t, const shared_ptr<_Tp>& __x) _NOEXCEPT #endif // _LIBCPP_STD_VER <= 17 -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template<class _Tp> _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(shared_ptr<_Tp> const& __x, nullptr_t) noexcept @@ -1530,6 +1558,15 @@ static_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT typename shared_ptr<_Tp>::element_type*>(__r.get())); } +// LWG-2996 +// We don't backport because it is an evolutionary change. +#if _LIBCPP_STD_VER >= 20 +template <class _Tp, class _Up> +_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> static_pointer_cast(shared_ptr<_Up>&& __r) noexcept { + return shared_ptr<_Tp>(std::move(__r), static_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); +} +#endif + template<class _Tp, class _Up> inline _LIBCPP_INLINE_VISIBILITY shared_ptr<_Tp> @@ -1540,6 +1577,16 @@ dynamic_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT return __p ? shared_ptr<_Tp>(__r, __p) : shared_ptr<_Tp>(); } +// LWG-2996 +// We don't backport because it is an evolutionary change. +#if _LIBCPP_STD_VER >= 20 +template <class _Tp, class _Up> +_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> dynamic_pointer_cast(shared_ptr<_Up>&& __r) noexcept { + auto* __p = dynamic_cast<typename shared_ptr<_Tp>::element_type*>(__r.get()); + return __p ? shared_ptr<_Tp>(std::move(__r), __p) : shared_ptr<_Tp>(); +} +#endif + template<class _Tp, class _Up> _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT @@ -1548,6 +1595,15 @@ const_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT return shared_ptr<_Tp>(__r, const_cast<_RTp*>(__r.get())); } +// LWG-2996 +// We don't backport because it is an evolutionary change. +#if _LIBCPP_STD_VER >= 20 +template <class _Tp, class _Up> +_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> const_pointer_cast(shared_ptr<_Up>&& __r) noexcept { + return shared_ptr<_Tp>(std::move(__r), const_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); +} +#endif + template<class _Tp, class _Up> _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT @@ -1557,6 +1613,15 @@ reinterpret_pointer_cast(const shared_ptr<_Up>& __r) _NOEXCEPT typename shared_ptr<_Tp>::element_type*>(__r.get())); } +// LWG-2996 +// We don't backport because it is an evolutionary change. +#if _LIBCPP_STD_VER >= 20 +template <class _Tp, class _Up> +_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& __r) noexcept { + return shared_ptr<_Tp>(std::move(__r), reinterpret_cast<typename shared_ptr<_Tp>::element_type*>(__r.get())); +} +#endif + #ifndef _LIBCPP_HAS_NO_RTTI template<class _Dp, class _Tp> @@ -1573,7 +1638,7 @@ template<class _Tp> class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr { public: -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 typedef remove_extent_t<_Tp> element_type; #else typedef _Tp element_type; @@ -1600,7 +1665,7 @@ public: template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) _NOEXCEPT; - ~weak_ptr(); + _LIBCPP_HIDE_FROM_ABI ~weak_ptr(); _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; @@ -1644,7 +1709,7 @@ public: _LIBCPP_INLINE_VISIBILITY bool expired() const _NOEXCEPT {return __cntrl_ == nullptr || __cntrl_->use_count() == 0;} - shared_ptr<_Tp> lock() const _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> lock() const _NOEXCEPT; template<class _Up> _LIBCPP_INLINE_VISIBILITY bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT @@ -1658,7 +1723,7 @@ public: template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; }; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template<class _Tp> weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; #endif @@ -1834,7 +1899,7 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT return __r; } -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <class _Tp = void> struct owner_less; #else template <class _Tp> struct owner_less; @@ -1871,7 +1936,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > {return __x.owner_before(__y);} }; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <> struct _LIBCPP_TEMPLATE_VIS owner_less<void> { @@ -1917,7 +1982,7 @@ public: shared_ptr<_Tp const> shared_from_this() const {return shared_ptr<const _Tp>(__weak_this_);} -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 _LIBCPP_INLINE_VISIBILITY weak_ptr<_Tp> weak_from_this() _NOEXCEPT { return __weak_this_; } @@ -1925,7 +1990,7 @@ public: _LIBCPP_INLINE_VISIBILITY weak_ptr<const _Tp> weak_from_this() const _NOEXCEPT { return __weak_this_; } -#endif // _LIBCPP_STD_VER > 14 +#endif // _LIBCPP_STD_VER >= 17 template <class _Up> friend class shared_ptr; }; @@ -1955,7 +2020,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); #if !defined(_LIBCPP_HAS_NO_THREADS) -class _LIBCPP_TYPE_VIS __sp_mut +class _LIBCPP_EXPORTED_FROM_ABI __sp_mut { void* __lx_; public: @@ -1967,10 +2032,10 @@ private: __sp_mut(const __sp_mut&); __sp_mut& operator=(const __sp_mut&); - friend _LIBCPP_FUNC_VIS __sp_mut& __get_sp_mut(const void*); + friend _LIBCPP_EXPORTED_FROM_ABI __sp_mut& __get_sp_mut(const void*); }; -_LIBCPP_FUNC_VIS _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR +_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR __sp_mut& __get_sp_mut(const void*); template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/swap_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/swap_allocator.h index c6e1751f4d..90851cb79c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/swap_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/swap_allocator.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <typename _Alloc> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type) -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER >= 14 _NOEXCEPT #else _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) @@ -39,7 +39,7 @@ __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {} template <typename _Alloc> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc& __a1, _Alloc& __a2) -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER >= 14 _NOEXCEPT #else _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/temp_value.h b/contrib/libs/cxxsupp/libcxx/include/__memory/temp_value.h index 164688b15f..3ce8b4bcbb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/temp_value.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/temp_value.h @@ -32,7 +32,7 @@ struct __temp_value { #endif _Alloc &__a; - _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp *__addr() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp *__addr() { #ifdef _LIBCPP_CXX03_LANG return reinterpret_cast<_Tp*>(std::addressof(__v)); #else @@ -40,15 +40,15 @@ struct __temp_value { #endif } - _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp & get() { return *__addr(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp & get() { return *__addr(); } template<class... _Args> - _LIBCPP_NO_CFI + _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX20 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...); } - _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__temp_value() { _Traits::destroy(__a, __addr()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__temp_value() { _Traits::destroy(__a, __addr()); } }; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h index fa4881e0be..058ff463b4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uninitialized_algorithms.h @@ -12,6 +12,8 @@ #include <__algorithm/copy.h> #include <__algorithm/move.h> +#include <__algorithm/unwrap_iter.h> +#include <__algorithm/unwrap_range.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> @@ -58,12 +60,12 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _Sentinel2 __olast) { _ForwardIterator __idx = __ofirst; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __ifirst != __ilast && __idx != __olast; ++__ifirst, (void)++__idx) ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__ofirst, __idx); throw; @@ -90,12 +92,12 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _Sentinel __olast) { _ForwardIterator __idx = __ofirst; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __n > 0 && __idx != __olast; ++__ifirst, (void)++__idx, (void)--__n) ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__ofirst, __idx); throw; @@ -121,13 +123,13 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) { _ForwardIterator __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __idx != __last; ++__idx) ::new (_VSTD::__voidify(*__idx)) _ValueType(__x); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { @@ -154,13 +156,13 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { _ForwardIterator __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __n > 0; ++__idx, (void) --__n) ::new (_VSTD::__voidify(*__idx)) _ValueType(__x); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { @@ -180,7 +182,7 @@ _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const return _VSTD::__uninitialized_fill_n<_ValueType>(__first, __n, __x); } -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 // uninitialized_default_construct @@ -188,12 +190,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel> inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { auto __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __idx != __last; ++__idx) ::new (_VSTD::__voidify(*__idx)) _ValueType; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__first, __idx); throw; @@ -217,12 +219,12 @@ template <class _ValueType, class _ForwardIterator, class _Size> inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { auto __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __n > 0; ++__idx, (void) --__n) ::new (_VSTD::__voidify(*__idx)) _ValueType; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__first, __idx); throw; @@ -245,12 +247,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel> inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { auto __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __idx != __last; ++__idx) ::new (_VSTD::__voidify(*__idx)) _ValueType(); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__first, __idx); throw; @@ -274,12 +276,12 @@ template <class _ValueType, class _ForwardIterator, class _Size> inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { auto __idx = __first; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __n > 0; ++__idx, (void) --__n) ::new (_VSTD::__voidify(*__idx)) _ValueType(); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__first, __idx); throw; @@ -304,13 +306,13 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move(_InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _Sentinel2 __olast, _IterMove __iter_move) { auto __idx = __ofirst; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __ifirst != __ilast && __idx != __olast; ++__idx, (void)++__ifirst) { ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); } -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__ofirst, __idx); throw; @@ -338,12 +340,12 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _Sentinel __olast, _IterMove __iter_move) { auto __idx = __ofirst; -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS try { #endif for (; __n > 0 && __idx != __olast; ++__idx, (void)++__ifirst, --__n) ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS } catch (...) { _VSTD::__destroy(__ofirst, __idx); throw; @@ -371,7 +373,7 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir // This function assumes that destructors do not throw, and that the allocator is bound to // the correct type. template<class _Alloc, class _BidirIter, class = __enable_if_t< - __is_cpp17_bidirectional_iterator<_BidirIter>::value + __has_bidirectional_iterator_category<_BidirIter>::value >> _LIBCPP_HIDE_FROM_ABI constexpr void __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept { @@ -512,7 +514,7 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B __guard.__complete(); } -#endif // _LIBCPP_STD_VER > 14 +#endif // _LIBCPP_STD_VER >= 17 // Destroy all elements in [__first, __last) from left to right using allocator destruction. template <class _Alloc, class _Iter, class _Sent> @@ -545,7 +547,7 @@ private: // already copied elements are destroyed in reverse order of their construction. template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 -__uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { +__uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { auto __destruct_first = __first2; auto __guard = std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)); @@ -566,14 +568,16 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty #ifndef __CUDACC__ template <class _Alloc, - class _Type, - class _RawType = __remove_const_t<_Type>, + class _In, + class _RawTypeIn = __remove_const_t<_In>, + class _Out, __enable_if_t< - // using _RawType because of the allocator<T const> extension - is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value && - __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Type* -__uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) { + // using _RawTypeIn because of the allocator<T const> extension + is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && + is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && + __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value>* = nullptr> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* +__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) { // TODO: Remove the const_cast once we drop support for std::allocator<T const> if (__libcpp_is_constant_evaluated()) { while (__first1 != __last1) { @@ -583,10 +587,17 @@ __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __la } return __first2; } else { - return std::copy(__first1, __last1, const_cast<_RawType*>(__first2)); + return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2)); } } -#endif // !__CUDACC__ +#endif // __CUDACC__ + +template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { + auto __unwrapped_range = std::__unwrap_range(__first1, __last1); + auto __result = std::__uninitialized_allocator_copy_impl(__alloc, __unwrapped_range.first, __unwrapped_range.second, std::__unwrap_iter(__first2)); + return std::__rewrap_iter(__first2, __result); +} // Move-construct the elements [__first1, __last1) into [__first2, __first2 + N) // if the move constructor is noexcept, where N is distance(__first1, __last1). @@ -602,7 +613,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 __uninitialized_alloc auto __guard = std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)); while (__first1 != __last1) { -#ifndef _LIBCPP_NO_EXCEPTIONS +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1)); #else allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1)); diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h index 333691f715..e554d1a857 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h @@ -45,6 +45,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> @@ -116,7 +119,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> { }; #if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI) -# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((trivial_abi)) +# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__)) #else # define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI #endif @@ -557,7 +560,7 @@ bool operator>=(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return !(__x < __y);} -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _T1, class _D1, class _T2, class _D2> requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer> @@ -651,7 +654,7 @@ operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x) { return !(nullptr < __x); } -#if _LIBCPP_STD_VER > 17 +#if _LIBCPP_STD_VER >= 20 template <class _T1, class _D1> requires three_way_comparable< typename unique_ptr<_T1, _D1>::pointer> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 @@ -661,7 +664,7 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) { } #endif -#if _LIBCPP_STD_VER > 11 +#if _LIBCPP_STD_VER >= 14 template<class _Tp> struct __unique_if @@ -698,7 +701,7 @@ template<class _Tp, class... _Args> typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete; -#endif // _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_STD_VER >= 14 #if _LIBCPP_STD_VER >= 20 @@ -744,4 +747,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_UNIQUE_PTR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h index fe89704027..f82ac17963 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator.h @@ -49,9 +49,9 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator { }; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <class _Tp, class _Alloc> -inline constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; +inline constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; #endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h index 0f63b080da..a2e4f6e26f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h @@ -23,6 +23,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 @@ -83,7 +86,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) std::forward_as_tuple(std::forward<_Vp>(__v))); } -# if _LIBCPP_STD_VER > 20 +# if _LIBCPP_STD_VER >= 23 template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { @@ -109,7 +112,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pai std::forward_as_tuple(std::get<1>(std::move(__pair)))); } -# if _LIBCPP_STD_VER > 20 +# if _LIBCPP_STD_VER >= 23 template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { @@ -218,4 +221,6 @@ uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Ar _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H |