diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-10 17:53:52 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-02-10 17:53:52 +0300 |
commit | 5c64b97bb7e4034eff8833e4c367f61d34fcb4ee (patch) | |
tree | 7c5769528f2fcdaa5a718aa73e4aa64d50905269 /contrib/libs/cxxsupp | |
parent | 1b56f620ac98766b198121ca1b728e7e61efbb56 (diff) | |
download | ydb-5c64b97bb7e4034eff8833e4c367f61d34fcb4ee.tar.gz |
intermediate changes
ref:4635f4dd763168c3fa295f87727595c785b4d5a4
Diffstat (limited to 'contrib/libs/cxxsupp')
42 files changed, 1297 insertions, 1452 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/.clang-format b/contrib/libs/cxxsupp/libcxx/.clang-format index 4598f60a00..527b629c38 100644 --- a/contrib/libs/cxxsupp/libcxx/.clang-format +++ b/contrib/libs/cxxsupp/libcxx/.clang-format @@ -2,7 +2,8 @@ BasedOnStyle: LLVM --- Language: Cpp -Standard: Cpp03 +Standard: c++20 +SpacesInAngles: Leave AlwaysBreakTemplateDeclarations: true PointerAlignment: Left diff --git a/contrib/libs/cxxsupp/libcxx/import b/contrib/libs/cxxsupp/libcxx/import index 9b93145897..f1067aab39 100755 --- a/contrib/libs/cxxsupp/libcxx/import +++ b/contrib/libs/cxxsupp/libcxx/import @@ -1,6 +1,6 @@ #!/bin/sh -e -rev=968e2739 +rev=dce5fc56 output_dir="libcxx-r$rev" if [ -z $1 ] ; then git clone https://github.com/llvm/llvm-project.git --no-checkout "$output_dir/tmp" diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h index 1cb7ee6a49..b4fe5cc7b1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_context.h @@ -70,9 +70,28 @@ __format_context_create( } #endif +// TODO FMT Implement [format.context]/4 +// [Note 1: For a given type charT, implementations are encouraged to provide a +// single instantiation of basic_format_context for appending to +// basic_string<charT>, vector<charT>, or any other container with contiguous +// storage by wrapping those in temporary objects with a uniform interface +// (such as a span<charT>) and polymorphic reallocation. - end note] + +using format_context = basic_format_context<back_insert_iterator<string>, char>; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>; +#endif + template <class _OutIt, class _CharT> requires output_iterator<_OutIt, const _CharT&> -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context { +class + // clang-format off + _LIBCPP_TEMPLATE_VIS + _LIBCPP_AVAILABILITY_FORMAT + _LIBCPP_PREFERRED_NAME(format_context) + _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) + // clang-format on + basic_format_context { public: using iterator = _OutIt; using char_type = _CharT; @@ -138,18 +157,6 @@ private: #endif }; -// TODO FMT Implement [format.context]/4 -// [Note 1: For a given type charT, implementations are encouraged to provide a -// single instantiation of basic_format_context for appending to -// basic_string<charT>, vector<charT>, or any other container with contiguous -// storage by wrapping those in temporary objects with a uniform interface -// (such as a span<charT>) and polymorphic reallocation. - end note] - -using format_context = basic_format_context<back_insert_iterator<string>, char>; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>; -#endif - #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h index 77ee380936..9b713b8114 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h @@ -303,7 +303,7 @@ protected: return __r.__ptr; } - void _LIBCPP_HIDE_FROM_ABI constexpr __substitute_width_arg_id(auto __arg) { + _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) { _LIBCPP_ASSERT(__width_as_arg == 1, "Substitute width called when no substitution is required"); @@ -395,7 +395,7 @@ protected: return __r.__ptr; } - void _LIBCPP_HIDE_FROM_ABI constexpr __substitute_precision_arg_id( + _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id( auto __arg) { _LIBCPP_ASSERT( __precision_as_arg == 1 && __precision != __format::__number_max, @@ -576,7 +576,7 @@ private: } /** Processes the parsed std-format-spec based on the parsed display type. */ - void _LIBCPP_HIDE_FROM_ABI constexpr __process_display_type() { + _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { switch (this->__type) { case _Flags::_Type::__default: case _Flags::_Type::__string: diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h index 0a978914b1..28872f9fa4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h @@ -13,6 +13,7 @@ #include <__config> #include <__debug> #include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> #include <__memory/pointer_traits.h> #include <type_traits> @@ -54,7 +55,7 @@ public: : __i(__u.base()) { #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__iterator_copy(this, &__u); + __get_db()->__iterator_copy(this, _VSTD::addressof(__u)); #endif } #if _LIBCPP_DEBUG_LEVEL == 2 @@ -62,14 +63,14 @@ public: __wrap_iter(const __wrap_iter& __x) : __i(__x.base()) { - __get_db()->__iterator_copy(this, &__x); + __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); } _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator=(const __wrap_iter& __x) { - if (this != &__x) + if (this != _VSTD::addressof(__x)) { - __get_db()->__iterator_copy(this, &__x); + __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); __i = __x.__i; } return *this; @@ -180,7 +181,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), "Attempted to compare incomparable iterators"); #endif return __x.base() < __y.base(); @@ -264,7 +265,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC #endif // C++03 { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), "Attempted to subtract incompatible iterators"); #endif return __x.base() - __y.base(); diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h index 7913a19c10..c174994ddf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h @@ -98,8 +98,7 @@ public: _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp* allocate(size_t __n) { if (__n > allocator_traits<allocator>::max_size(*this)) - __throw_length_error("allocator<T>::allocate(size_t n)" - " 'n' exceeds maximum supported size"); + __throw_bad_array_new_length(); if (__libcpp_is_constant_evaluated()) { return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); } else { @@ -181,8 +180,7 @@ public: _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const _Tp* allocate(size_t __n) { if (__n > allocator_traits<allocator>::max_size(*this)) - __throw_length_error("allocator<const T>::allocate(size_t n)" - " 'n' exceeds maximum supported size"); + __throw_bad_array_new_length(); if (__libcpp_is_constant_evaluated()) { return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp))); } else { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h index f4c8fa02d6..cc32352ae1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator_traits.h @@ -349,6 +349,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits } }; +// A version of `allocator_traits` for internal usage that SFINAEs away if the +// given allocator doesn't have a nested `value_type`. This helps avoid hard +// errors when forming implicit deduction guides for a container that has an +// invalid Allocator type. See https://wg21.link/LWGXXXXX. +// TODO(varconst): use the actual link once available. +template <class _Alloc, class _ValueType = typename _Alloc::value_type> +struct _LIBCPP_TEMPLATE_VIS __allocator_traits : allocator_traits<_Alloc> {}; + template <class _Traits, class _Tp> struct __rebind_alloc_helper { #ifndef _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h index 6d844760c8..1179b8a610 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h @@ -31,7 +31,7 @@ #include <typeinfo> #include <type_traits> #include <utility> -#if !defined(_LIBCPP_HAS_NO_THREADS) //!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) +#if !defined(_LIBCPP_HAS_NO_THREADS) // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include <atomic> #endif @@ -157,7 +157,6 @@ protected: typedef atomic<long> __atomic_count; #endif __atomic_count __shared_owners_; - virtual ~__shared_count(); private: virtual void __on_zero_shared() _NOEXCEPT = 0; @@ -459,12 +458,18 @@ private: element_type* __ptr_; __shared_weak_count* __cntrl_; - struct __nat {int __for_bool_;}; public: - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI + _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT + : __ptr_(nullptr), + __cntrl_(nullptr) + { } + + _LIBCPP_HIDE_FROM_ABI + _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT + : __ptr_(nullptr), + __cntrl_(nullptr) + { } template<class _Yp, class = __enable_if_t< _And< @@ -486,638 +491,483 @@ public: __enable_weak_this(__p, __p); } - template<class _Yp, class _Dp> - shared_ptr(_Yp* __p, _Dp __d, - typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat()); - template<class _Yp, class _Dp, class _Alloc> - shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, - typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat()); - template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); - template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); - template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - shared_ptr(const shared_ptr& __r) _NOEXCEPT; - template<class _Yp> - _LIBCPP_INLINE_VISIBILITY - shared_ptr(const shared_ptr<_Yp>& __r, - typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) - _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - shared_ptr(shared_ptr&& __r) _NOEXCEPT; - template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, - typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) - _NOEXCEPT; - template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat()); -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) - template<class _Yp> - shared_ptr(auto_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); -#endif - template <class _Yp, class _Dp> - shared_ptr(unique_ptr<_Yp, _Dp>&&, - typename enable_if - < - !is_lvalue_reference<_Dp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, - __nat - >::type = __nat()); - template <class _Yp, class _Dp> - shared_ptr(unique_ptr<_Yp, _Dp>&&, - typename enable_if - < - is_lvalue_reference<_Dp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, - __nat - >::type = __nat()); - - ~shared_ptr(); + template<class _Yp, class _Dp, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(_Yp* __p, _Dp __d) + : __ptr_(__p) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; + typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; +#ifndef _LIBCPP_CXX03_LANG + __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); +#else + __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); +#endif // not _LIBCPP_CXX03_LANG + __enable_weak_this(__p, __p); +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + __d(__p); + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS + } - _LIBCPP_INLINE_VISIBILITY - shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; - template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, typename _VSTD::shared_ptr<_Tp>::element_type>::value, - shared_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY - operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; - template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, typename _VSTD::shared_ptr<_Tp>::element_type>::value, - shared_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY - operator=(shared_ptr<_Yp>&& __r); -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) - template<class _Yp> - _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - !is_array<_Yp>::value && - is_convertible<_Yp*, typename _VSTD::shared_ptr<_Tp>::element_type*>::value, - shared_ptr - >::type& - operator=(auto_ptr<_Yp>&& __r); -#endif - template <class _Yp, class _Dp> - typename enable_if - < - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, typename _VSTD::shared_ptr<_Tp>::element_type*>::value, - shared_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY - operator=(unique_ptr<_Yp, _Dp>&& __r); + template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) + : __ptr_(__p) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; + typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; + typedef __allocator_destructor<_A2> _D2; + _A2 __a2(__a); + unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); + ::new ((void*)_VSTD::addressof(*__hold2.get())) +#ifndef _LIBCPP_CXX03_LANG + _CntrlBlk(__p, _VSTD::move(__d), __a); +#else + _CntrlBlk(__p, __d, __a); +#endif // not _LIBCPP_CXX03_LANG + __cntrl_ = _VSTD::addressof(*__hold2.release()); + __enable_weak_this(__p, __p); +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + __d(__p); + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS + } + + template<class _Dp> + _LIBCPP_HIDE_FROM_ABI + shared_ptr(nullptr_t __p, _Dp __d) + : __ptr_(nullptr) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; + typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk; +#ifndef _LIBCPP_CXX03_LANG + __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); +#else + __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); +#endif // not _LIBCPP_CXX03_LANG +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + __d(__p); + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS + } + + template<class _Dp, class _Alloc> + _LIBCPP_HIDE_FROM_ABI + shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) + : __ptr_(nullptr) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_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; + _A2 __a2(__a); + unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); + ::new ((void*)_VSTD::addressof(*__hold2.get())) +#ifndef _LIBCPP_CXX03_LANG + _CntrlBlk(__p, _VSTD::move(__d), __a); +#else + _CntrlBlk(__p, __d, __a); +#endif // not _LIBCPP_CXX03_LANG + __cntrl_ = _VSTD::addressof(*__hold2.release()); +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch (...) + { + __d(__p); + throw; + } +#endif // _LIBCPP_NO_EXCEPTIONS + } - _LIBCPP_INLINE_VISIBILITY - void swap(shared_ptr& __r) _NOEXCEPT; - _LIBCPP_INLINE_VISIBILITY - void reset() _NOEXCEPT; template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, typename _VSTD::shared_ptr<_Tp>::element_type>::value, - void - >::type - _LIBCPP_INLINE_VISIBILITY - reset(_Yp* __p); - template<class _Yp, class _Dp> - typename enable_if - < - __compatible_with<_Yp, typename _VSTD::shared_ptr<_Tp>::element_type>::value, - void - >::type - _LIBCPP_INLINE_VISIBILITY - reset(_Yp* __p, _Dp __d); - template<class _Yp, class _Dp, class _Alloc> - typename enable_if - < - __compatible_with<_Yp, typename _VSTD::shared_ptr<_Tp>::element_type>::value, - void - >::type - _LIBCPP_INLINE_VISIBILITY - reset(_Yp* __p, _Dp __d, _Alloc __a); + _LIBCPP_HIDE_FROM_ABI + shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT + : __ptr_(__p), + __cntrl_(__r.__cntrl_) + { + if (__cntrl_) + __cntrl_->__add_shared(); + } - _LIBCPP_INLINE_VISIBILITY - element_type* get() const _NOEXCEPT {return __ptr_;} - _LIBCPP_INLINE_VISIBILITY - typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT - {return *__ptr_;} - _LIBCPP_INLINE_VISIBILITY - element_type* operator->() const _NOEXCEPT + _LIBCPP_HIDE_FROM_ABI + shared_ptr(const shared_ptr& __r) _NOEXCEPT + : __ptr_(__r.__ptr_), + __cntrl_(__r.__cntrl_) { - static_assert(!is_array<_Tp>::value, - "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); - return __ptr_; + if (__cntrl_) + __cntrl_->__add_shared(); } - _LIBCPP_INLINE_VISIBILITY - long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} - _LIBCPP_INLINE_VISIBILITY - bool unique() const _NOEXCEPT {return use_count() == 1;} - _LIBCPP_INLINE_VISIBILITY - explicit operator bool() const _NOEXCEPT {return get() != nullptr;} - template <class _Up> - _LIBCPP_INLINE_VISIBILITY - bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT - {return __cntrl_ < __p.__cntrl_;} - template <class _Up> - _LIBCPP_INLINE_VISIBILITY - bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT - {return __cntrl_ < __p.__cntrl_;} - _LIBCPP_INLINE_VISIBILITY - bool - __owner_equivalent(const shared_ptr& __p) const - {return __cntrl_ == __p.__cntrl_;} -#if _LIBCPP_STD_VER > 14 - typename add_lvalue_reference<element_type>::type - _LIBCPP_INLINE_VISIBILITY - operator[](ptrdiff_t __i) const + template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT + : __ptr_(__r.__ptr_), + __cntrl_(__r.__cntrl_) { - static_assert(is_array<_Tp>::value, - "std::shared_ptr<T>::operator[] is only valid when T is an array type."); - return __ptr_[__i]; + if (__cntrl_) + __cntrl_->__add_shared(); } -#endif -#ifndef _LIBCPP_NO_RTTI - template <class _Dp> - _LIBCPP_INLINE_VISIBILITY - _Dp* __get_deleter() const _NOEXCEPT - {return static_cast<_Dp*>(__cntrl_ - ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp))) - : nullptr);} -#endif // _LIBCPP_NO_RTTI + _LIBCPP_HIDE_FROM_ABI + shared_ptr(shared_ptr&& __r) _NOEXCEPT + : __ptr_(__r.__ptr_), + __cntrl_(__r.__cntrl_) + { + __r.__ptr_ = nullptr; + __r.__cntrl_ = nullptr; + } - template<class _Yp, class _CntrlBlk> - static shared_ptr<_Tp> - __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT + template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT + : __ptr_(__r.__ptr_), + __cntrl_(__r.__cntrl_) { - shared_ptr<_Tp> __r; - __r.__ptr_ = __p; - __r.__cntrl_ = __cntrl; - __r.__enable_weak_this(__r.__ptr_, __r.__ptr_); - return __r; + __r.__ptr_ = nullptr; + __r.__cntrl_ = nullptr; } -private: - template <class _Yp, bool = is_function<_Yp>::value> - struct __shared_ptr_default_allocator - { - typedef allocator<_Yp> type; - }; + template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > + _LIBCPP_HIDE_FROM_ABI + explicit shared_ptr(const weak_ptr<_Yp>& __r) + : __ptr_(__r.__ptr_), + __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) + { + if (__cntrl_ == nullptr) + __throw_bad_weak_ptr(); + } - template <class _Yp> - struct __shared_ptr_default_allocator<_Yp, true> +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) + template<class _Yp, class = __enable_if_t<is_convertible<_Yp*, element_type*>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(auto_ptr<_Yp>&& __r) + : __ptr_(__r.get()) + { + typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; + __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); + __enable_weak_this(__r.get(), __r.get()); + __r.release(); + } +#endif + + template <class _Yp, class _Dp, class = __enable_if_t< + !is_lvalue_reference<_Dp>::value && + is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value + > > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(unique_ptr<_Yp, _Dp>&& __r) + : __ptr_(__r.get()) + { +#if _LIBCPP_STD_VER > 11 + if (__ptr_ == nullptr) + __cntrl_ = nullptr; + else +#endif { - typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type; - }; + typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; + typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk; + __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT()); + __enable_weak_this(__r.get(), __r.get()); + } + __r.release(); + } - template <class _Yp, class _OrigPtr> - _LIBCPP_INLINE_VISIBILITY - typename enable_if<is_convertible<_OrigPtr*, - const enable_shared_from_this<_Yp>* - >::value, - void>::type - __enable_weak_this(const enable_shared_from_this<_Yp>* __e, - _OrigPtr* __ptr) _NOEXCEPT + template <class _Yp, class _Dp, class = void, class = __enable_if_t< + is_lvalue_reference<_Dp>::value && + is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value + > > + _LIBCPP_HIDE_FROM_ABI + shared_ptr(unique_ptr<_Yp, _Dp>&& __r) + : __ptr_(__r.get()) + { +#if _LIBCPP_STD_VER > 11 + if (__ptr_ == nullptr) + __cntrl_ = nullptr; + else +#endif { - typedef typename remove_cv<_Yp>::type _RawYp; - if (__e && __e->__weak_this_.expired()) - { - __e->__weak_this_ = shared_ptr<_RawYp>(*this, - const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr))); - } + typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; + typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, + reference_wrapper<typename remove_reference<_Dp>::type>, + _AllocT > _CntrlBlk; + __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); + __enable_weak_this(__r.get(), __r.get()); } + __r.release(); + } - _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} + _LIBCPP_HIDE_FROM_ABI + ~shared_ptr() + { + if (__cntrl_) + __cntrl_->__release_shared(); + } - template <class, class _Yp> - struct __shared_ptr_default_delete - : default_delete<_Yp> {}; + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(const shared_ptr& __r) _NOEXCEPT + { + shared_ptr(__r).swap(*this); + return *this; + } - template <class _Yp, class _Un, size_t _Sz> - struct __shared_ptr_default_delete<_Yp[_Sz], _Un> - : default_delete<_Yp[]> {}; + template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT + { + shared_ptr(__r).swap(*this); + return *this; + } - template <class _Yp, class _Un> - struct __shared_ptr_default_delete<_Yp[], _Un> - : default_delete<_Yp[]> {}; + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(shared_ptr&& __r) _NOEXCEPT + { + shared_ptr(_VSTD::move(__r)).swap(*this); + return *this; + } - template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; - template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; -}; + template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) + { + shared_ptr(_VSTD::move(__r)).swap(*this); + return *this; + } -#if _LIBCPP_STD_VER >= 17 -template<class _Tp> -shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; -template<class _Tp, class _Dp> -shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) + template<class _Yp, class = __enable_if_t< + !is_array<_Yp>::value && + is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value + > > + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r) + { + shared_ptr(_VSTD::move(__r)).swap(*this); + return *this; + } #endif -template<class _Tp> -inline -_LIBCPP_CONSTEXPR -shared_ptr<_Tp>::shared_ptr() _NOEXCEPT - : __ptr_(nullptr), - __cntrl_(nullptr) -{ -} + template <class _Yp, class _Dp, class = __enable_if_t< + is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value + > > + _LIBCPP_HIDE_FROM_ABI + shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) + { + shared_ptr(_VSTD::move(__r)).swap(*this); + return *this; + } -template<class _Tp> -inline -_LIBCPP_CONSTEXPR -shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT - : __ptr_(nullptr), - __cntrl_(nullptr) -{ -} + _LIBCPP_HIDE_FROM_ABI + void swap(shared_ptr& __r) _NOEXCEPT + { + _VSTD::swap(__ptr_, __r.__ptr_); + _VSTD::swap(__cntrl_, __r.__cntrl_); + } -template<class _Tp> -template<class _Yp, class _Dp> -shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, - typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type) - : __ptr_(__p) -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - try + _LIBCPP_HIDE_FROM_ABI + void reset() _NOEXCEPT { -#endif // _LIBCPP_NO_EXCEPTIONS - typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; - typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; -#ifndef _LIBCPP_CXX03_LANG - __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); -#else - __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); -#endif // not _LIBCPP_CXX03_LANG - __enable_weak_this(__p, __p); -#ifndef _LIBCPP_NO_EXCEPTIONS + shared_ptr().swap(*this); } - catch (...) + + template<class _Yp, class = __enable_if_t< + __compatible_with<_Yp, _Tp>::value + > > + _LIBCPP_HIDE_FROM_ABI + void reset(_Yp* __p) { - __d(__p); - throw; + shared_ptr(__p).swap(*this); } -#endif // _LIBCPP_NO_EXCEPTIONS -} -template<class _Tp> -template<class _Dp> -shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) - : __ptr_(nullptr) -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - try + template<class _Yp, class _Dp, class = __enable_if_t< + __compatible_with<_Yp, _Tp>::value + > > + _LIBCPP_HIDE_FROM_ABI + void reset(_Yp* __p, _Dp __d) { -#endif // _LIBCPP_NO_EXCEPTIONS - typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; - typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk; -#ifndef _LIBCPP_CXX03_LANG - __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); -#else - __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); -#endif // not _LIBCPP_CXX03_LANG -#ifndef _LIBCPP_NO_EXCEPTIONS + shared_ptr(__p, __d).swap(*this); } - catch (...) + + template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t< + __compatible_with<_Yp, _Tp>::value + > > + _LIBCPP_HIDE_FROM_ABI + void reset(_Yp* __p, _Dp __d, _Alloc __a) { - __d(__p); - throw; + shared_ptr(__p, __d, __a).swap(*this); } -#endif // _LIBCPP_NO_EXCEPTIONS -} -template<class _Tp> -template<class _Yp, class _Dp, class _Alloc> -shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, - typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type) - : __ptr_(__p) -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - try + _LIBCPP_HIDE_FROM_ABI + element_type* get() const _NOEXCEPT { -#endif // _LIBCPP_NO_EXCEPTIONS - typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; - typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; - typedef __allocator_destructor<_A2> _D2; - _A2 __a2(__a); - unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); - ::new ((void*)_VSTD::addressof(*__hold2.get())) -#ifndef _LIBCPP_CXX03_LANG - _CntrlBlk(__p, _VSTD::move(__d), __a); -#else - _CntrlBlk(__p, __d, __a); -#endif // not _LIBCPP_CXX03_LANG - __cntrl_ = _VSTD::addressof(*__hold2.release()); - __enable_weak_this(__p, __p); -#ifndef _LIBCPP_NO_EXCEPTIONS + return __ptr_; } - catch (...) + + _LIBCPP_HIDE_FROM_ABI + typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT { - __d(__p); - throw; + return *__ptr_; } -#endif // _LIBCPP_NO_EXCEPTIONS -} -template<class _Tp> -template<class _Dp, class _Alloc> -shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) - : __ptr_(nullptr) -{ -#ifndef _LIBCPP_NO_EXCEPTIONS - try + _LIBCPP_HIDE_FROM_ABI + element_type* operator->() const _NOEXCEPT { -#endif // _LIBCPP_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; - _A2 __a2(__a); - unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); - ::new ((void*)_VSTD::addressof(*__hold2.get())) -#ifndef _LIBCPP_CXX03_LANG - _CntrlBlk(__p, _VSTD::move(__d), __a); -#else - _CntrlBlk(__p, __d, __a); -#endif // not _LIBCPP_CXX03_LANG - __cntrl_ = _VSTD::addressof(*__hold2.release()); -#ifndef _LIBCPP_NO_EXCEPTIONS + static_assert(!is_array<_Tp>::value, + "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); + return __ptr_; } - catch (...) + + _LIBCPP_HIDE_FROM_ABI + long use_count() const _NOEXCEPT { - __d(__p); - throw; + return __cntrl_ ? __cntrl_->use_count() : 0; } -#endif // _LIBCPP_NO_EXCEPTIONS -} -template<class _Tp> -template<class _Yp> -inline -shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT - : __ptr_(__p), - __cntrl_(__r.__cntrl_) -{ - if (__cntrl_) - __cntrl_->__add_shared(); -} + _LIBCPP_HIDE_FROM_ABI + bool unique() const _NOEXCEPT + { + return use_count() == 1; + } -template<class _Tp> -inline -shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) -{ - if (__cntrl_) - __cntrl_->__add_shared(); -} + _LIBCPP_HIDE_FROM_ABI + explicit operator bool() const _NOEXCEPT + { + return get() != nullptr; + } -template<class _Tp> -template<class _Yp> -inline -shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, - typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) - _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) -{ - if (__cntrl_) - __cntrl_->__add_shared(); -} + template <class _Up> + _LIBCPP_HIDE_FROM_ABI + bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT + { + return __cntrl_ < __p.__cntrl_; + } -template<class _Tp> -inline -shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) -{ - __r.__ptr_ = nullptr; - __r.__cntrl_ = nullptr; -} + template <class _Up> + _LIBCPP_HIDE_FROM_ABI + bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT + { + return __cntrl_ < __p.__cntrl_; + } -template<class _Tp> -template<class _Yp> -inline -shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, - typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) - _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) -{ - __r.__ptr_ = nullptr; - __r.__cntrl_ = nullptr; -} + _LIBCPP_HIDE_FROM_ABI + bool __owner_equivalent(const shared_ptr& __p) const + { + return __cntrl_ == __p.__cntrl_; + } -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) -template<class _Tp> -template<class _Yp> -shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) - : __ptr_(__r.get()) -{ - typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; - __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); - __enable_weak_this(__r.get(), __r.get()); - __r.release(); -} +#if _LIBCPP_STD_VER > 14 + _LIBCPP_HIDE_FROM_ABI + typename add_lvalue_reference<element_type>::type operator[](ptrdiff_t __i) const + { + static_assert(is_array<_Tp>::value, + "std::shared_ptr<T>::operator[] is only valid when T is an array type."); + return __ptr_[__i]; + } #endif -template<class _Tp> -template <class _Yp, class _Dp> -shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, - typename enable_if - < - !is_lvalue_reference<_Dp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, - __nat - >::type) - : __ptr_(__r.get()) -{ -#if _LIBCPP_STD_VER > 11 - if (__ptr_ == nullptr) - __cntrl_ = nullptr; - else -#endif +#ifndef _LIBCPP_NO_RTTI + template <class _Dp> + _LIBCPP_HIDE_FROM_ABI + _Dp* __get_deleter() const _NOEXCEPT { - typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; - typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk; - __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT()); - __enable_weak_this(__r.get(), __r.get()); + return static_cast<_Dp*>(__cntrl_ + ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp))) + : nullptr); } - __r.release(); -} +#endif // _LIBCPP_NO_RTTI -template<class _Tp> -template <class _Yp, class _Dp> -shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, - typename enable_if - < - is_lvalue_reference<_Dp>::value && - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, - __nat - >::type) - : __ptr_(__r.get()) -{ -#if _LIBCPP_STD_VER > 11 - if (__ptr_ == nullptr) - __cntrl_ = nullptr; - else -#endif + template<class _Yp, class _CntrlBlk> + _LIBCPP_HIDE_FROM_ABI + static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT { - typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; - typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, - reference_wrapper<typename remove_reference<_Dp>::type>, - _AllocT > _CntrlBlk; - __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); - __enable_weak_this(__r.get(), __r.get()); + shared_ptr<_Tp> __r; + __r.__ptr_ = __p; + __r.__cntrl_ = __cntrl; + __r.__enable_weak_this(__r.__ptr_, __r.__ptr_); + return __r; } - __r.release(); -} - -template<class _Tp> -shared_ptr<_Tp>::~shared_ptr() -{ - if (__cntrl_) - __cntrl_->__release_shared(); -} - -template<class _Tp> -inline -shared_ptr<_Tp>& -shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT -{ - shared_ptr(__r).swap(*this); - return *this; -} - -template<class _Tp> -template<class _Yp> -inline -typename enable_if -< - __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, - shared_ptr<_Tp>& ->::type -shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT -{ - shared_ptr(__r).swap(*this); - return *this; -} -template<class _Tp> -inline -shared_ptr<_Tp>& -shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT -{ - shared_ptr(_VSTD::move(__r)).swap(*this); - return *this; -} +private: + template <class _Yp, bool = is_function<_Yp>::value> + struct __shared_ptr_default_allocator + { + typedef allocator<_Yp> type; + }; -template<class _Tp> -template<class _Yp> -inline -typename enable_if -< - __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, - shared_ptr<_Tp>& ->::type -shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) -{ - shared_ptr(_VSTD::move(__r)).swap(*this); - return *this; -} + template <class _Yp> + struct __shared_ptr_default_allocator<_Yp, true> + { + typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type; + }; -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) -template<class _Tp> -template<class _Yp> -inline -typename enable_if -< - !is_array<_Yp>::value && - is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, - shared_ptr<_Tp> ->::type& -shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) -{ - shared_ptr(_VSTD::move(__r)).swap(*this); - return *this; -} -#endif + template <class _Yp, class _OrigPtr, class = __enable_if_t< + is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value + > > + _LIBCPP_HIDE_FROM_ABI + void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT + { + typedef typename remove_cv<_Yp>::type _RawYp; + if (__e && __e->__weak_this_.expired()) + { + __e->__weak_this_ = shared_ptr<_RawYp>(*this, + const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr))); + } + } -template<class _Tp> -template <class _Yp, class _Dp> -inline -typename enable_if -< - is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, - typename shared_ptr<_Tp>::element_type*>::value, - shared_ptr<_Tp>& ->::type -shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) -{ - shared_ptr(_VSTD::move(__r)).swap(*this); - return *this; -} + _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(...) _NOEXCEPT { } -template<class _Tp> -inline -void -shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT -{ - _VSTD::swap(__ptr_, __r.__ptr_); - _VSTD::swap(__cntrl_, __r.__cntrl_); -} + template <class, class _Yp> + struct __shared_ptr_default_delete + : default_delete<_Yp> + { }; -template<class _Tp> -inline -void -shared_ptr<_Tp>::reset() _NOEXCEPT -{ - shared_ptr().swap(*this); -} + template <class _Yp, class _Un, size_t _Sz> + struct __shared_ptr_default_delete<_Yp[_Sz], _Un> + : default_delete<_Yp[]> + { }; -template<class _Tp> -template<class _Yp> -inline -typename enable_if -< - __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, - void ->::type -shared_ptr<_Tp>::reset(_Yp* __p) -{ - shared_ptr(__p).swap(*this); -} + template <class _Yp, class _Un> + struct __shared_ptr_default_delete<_Yp[], _Un> + : default_delete<_Yp[]> + { }; -template<class _Tp> -template<class _Yp, class _Dp> -inline -typename enable_if -< - __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, - void ->::type -shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) -{ - shared_ptr(__p, __d).swap(*this); -} + template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; + template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; +}; +#if _LIBCPP_STD_VER > 14 template<class _Tp> -template<class _Yp, class _Dp, class _Alloc> -inline -typename enable_if -< - __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, - void ->::type -shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) -{ - shared_ptr(__p, __d, __a).swap(*this); -} +shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; +template<class _Tp, class _Dp> +shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; +#endif // // std::allocate_shared and std::make_shared @@ -1352,7 +1202,12 @@ template<class _Tp> class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr { public: +#if _LIBCPP_STD_VER > 14 + typedef remove_extent_t<_Tp> element_type; +#else typedef _Tp element_type; +#endif + private: element_type* __ptr_; __shared_weak_count* __cntrl_; @@ -1361,18 +1216,18 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr const& __r) _NOEXCEPT; template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr&& __r) _NOEXCEPT; template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) _NOEXCEPT; ~weak_ptr(); @@ -1381,7 +1236,7 @@ public: template<class _Yp> typename enable_if < - is_convertible<_Yp*, element_type*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr& >::type _LIBCPP_INLINE_VISIBILITY @@ -1392,7 +1247,7 @@ public: template<class _Yp> typename enable_if < - is_convertible<_Yp*, element_type*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr& >::type _LIBCPP_INLINE_VISIBILITY @@ -1401,7 +1256,7 @@ public: template<class _Yp> typename enable_if < - is_convertible<_Yp*, element_type*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr& >::type _LIBCPP_INLINE_VISIBILITY @@ -1432,7 +1287,7 @@ public: template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; }; -#if _LIBCPP_STD_VER >= 17 +#if _LIBCPP_STD_VER > 14 template<class _Tp> weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; #endif @@ -1460,7 +1315,7 @@ template<class _Tp> template<class _Yp> inline weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -1473,7 +1328,7 @@ template<class _Tp> template<class _Yp> inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -1496,7 +1351,7 @@ template<class _Tp> template<class _Yp> inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, - typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) + typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -1526,7 +1381,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr<_Tp>& >::type weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT @@ -1549,7 +1404,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr<_Tp>& >::type weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT @@ -1563,7 +1418,7 @@ template<class _Yp> inline typename enable_if < - is_convertible<_Yp*, _Tp*>::value, + __compatible_with<_Yp, _Tp>::value, weak_ptr<_Tp>& >::type weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT @@ -1598,17 +1453,6 @@ weak_ptr<_Tp>::reset() _NOEXCEPT } template<class _Tp> -template<class _Yp> -shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, - typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) -{ - if (__cntrl_ == nullptr) - __throw_bad_weak_ptr(); -} - -template<class _Tp> shared_ptr<_Tp> weak_ptr<_Tp>::lock() const _NOEXCEPT { diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h index ad88dc7138..618be80457 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/reverse_view.h @@ -19,8 +19,11 @@ #include <__ranges/concepts.h> #include <__ranges/enable_borrowed_range.h> #include <__ranges/non_propagating_cache.h> +#include <__ranges/range_adaptor.h> #include <__ranges/size.h> +#include <__ranges/subrange.h> #include <__ranges/view_interface.h> +#include <__utility/forward.h> #include <__utility/move.h> #include <type_traits> @@ -104,6 +107,80 @@ namespace ranges { template<class _Tp> inline constexpr bool enable_borrowed_range<reverse_view<_Tp>> = enable_borrowed_range<_Tp>; + + namespace views { + namespace __reverse { + template<class _Tp> + constexpr bool __is_reverse_view = false; + + template<class _Tp> + constexpr bool __is_reverse_view<reverse_view<_Tp>> = true; + + template<class _Tp> + constexpr bool __is_sized_reverse_subrange = false; + + template<class _Iter> + constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true; + + template<class _Tp> + constexpr bool __is_unsized_reverse_subrange = false; + + template<class _Iter, subrange_kind _Kind> + constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized; + + template<class _Tp> + struct __unwrapped_reverse_subrange { + using type = void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics + }; + + template<class _Iter, subrange_kind _Kind> + struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> { + using type = subrange<_Iter, _Iter, _Kind>; + }; + + struct __fn : __range_adaptor_closure<__fn> { + template<class _Range> + requires __is_reverse_view<remove_cvref_t<_Range>> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Range&& __range) const + noexcept(noexcept(_VSTD::forward<_Range>(__range).base())) + -> decltype( _VSTD::forward<_Range>(__range).base()) + { return _VSTD::forward<_Range>(__range).base(); } + + template<class _Range, + class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type> + requires __is_sized_reverse_subrange<remove_cvref_t<_Range>> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Range&& __range) const + noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()))) + -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size())) + { return _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()); } + + template<class _Range, + class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type> + requires __is_unsized_reverse_subrange<remove_cvref_t<_Range>> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Range&& __range) const + noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base()))) + -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base())) + { return _UnwrappedSubrange(__range.end().base(), __range.begin().base()); } + + template<class _Range> + requires (!__is_reverse_view<remove_cvref_t<_Range>> && + !__is_sized_reverse_subrange<remove_cvref_t<_Range>> && + !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>) + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Range&& __range) const + noexcept(noexcept(reverse_view{_VSTD::forward<_Range>(__range)})) + -> decltype( reverse_view{_VSTD::forward<_Range>(__range)}) + { return reverse_view{_VSTD::forward<_Range>(__range)}; } + }; + } + + inline namespace __cpo { + inline constexpr auto reverse = __reverse::__fn{}; + } + } // namespace views } // namespace ranges #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h index 1c66dadfa1..8a1f5d8c92 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/view_interface.h @@ -43,11 +43,13 @@ template<class _Derived> class view_interface : public view_base { _LIBCPP_HIDE_FROM_ABI constexpr _Derived& __derived() noexcept { + static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>); return static_cast<_Derived&>(*this); } _LIBCPP_HIDE_FROM_ABI constexpr _Derived const& __derived() const noexcept { + static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>); return static_cast<_Derived const&>(*this); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__threading_support b/contrib/libs/cxxsupp/libcxx/include/__threading_support index 9b0de00dfc..7bf2363d20 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__threading_support +++ b/contrib/libs/cxxsupp/libcxx/include/__threading_support @@ -31,16 +31,9 @@ # undef _LIBCPP_EXTERNAL_THREADING #elif !defined(_LIBCPP_HAS_NO_THREADS) -#if defined(__APPLE__) || defined(__MVS__) -# define _LIBCPP_NO_NATIVE_SEMAPHORES -#endif - #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # include <pthread.h> # include <sched.h> -# ifndef _LIBCPP_NO_NATIVE_SEMAPHORES -# include <semaphore.h> -# endif #elif defined(_LIBCPP_HAS_THREAD_API_C11) # include <threads.h> #endif @@ -80,12 +73,6 @@ typedef pthread_mutex_t __libcpp_recursive_mutex_t; typedef pthread_cond_t __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER -#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES -// Semaphore -typedef sem_t __libcpp_semaphore_t; -# define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX -#endif - // Execute once typedef pthread_once_t __libcpp_exec_once_flag; #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT @@ -151,12 +138,6 @@ typedef void* __libcpp_recursive_mutex_t[5]; typedef void* __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER 0 -// Semaphore -typedef void* __libcpp_semaphore_t; -#if defined(_LIBCPP_HAS_THREAD_API_WIN32) -# define _LIBCPP_SEMAPHORE_MAX (::std::numeric_limits<long>::max()) -#endif - // Execute Once typedef void* __libcpp_exec_once_flag; #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 @@ -221,26 +202,6 @@ int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); -#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES - -// Semaphore -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem); - -_LIBCPP_THREAD_ABI_VISIBILITY -bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns); - -#endif // _LIBCPP_NO_NATIVE_SEMAPHORES - // Execute once _LIBCPP_THREAD_ABI_VISIBILITY int __libcpp_execute_once(__libcpp_exec_once_flag *flag, @@ -454,38 +415,6 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) return pthread_cond_destroy(__cv); } -#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES - -// Semaphore -bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init) -{ - return sem_init(__sem, 0, __init) == 0; -} - -bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem) -{ - return sem_destroy(__sem) == 0; -} - -bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem) -{ - return sem_post(__sem) == 0; -} - -bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem) -{ - return sem_wait(__sem) == 0; -} - -bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns) -{ - auto const __abs_time = chrono::system_clock::now().time_since_epoch() + __ns; - __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__abs_time); - return sem_timedwait(__sem, &__ts) == 0; -} - -#endif //_LIBCPP_NO_NATIVE_SEMAPHORES - // Execute once int __libcpp_execute_once(__libcpp_exec_once_flag *flag, void (*init_routine)()) { diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/decay_copy.h b/contrib/libs/cxxsupp/libcxx/include/__utility/decay_copy.h index 1a7b399d91..5c9716a892 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/decay_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/decay_copy.h @@ -21,9 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t) +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR +typename decay<_Tp>::type __decay_copy(_Tp&& __t) #if _LIBCPP_STD_VER > 17 - noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp> >) + noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp>>) #endif { return _VSTD::forward<_Tp>(__t); diff --git a/contrib/libs/cxxsupp/libcxx/include/charconv b/contrib/libs/cxxsupp/libcxx/include/charconv index 2fdab7f007..447cef97a2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/charconv +++ b/contrib/libs/cxxsupp/libcxx/include/charconv @@ -31,6 +31,8 @@ namespace std { to_chars_result to_chars(char* first, char* last, see below value, int base = 10); + to_chars_result to_chars(char* first, char* last, bool value, + int base = 10) = delete; to_chars_result to_chars(char* first, char* last, float value); to_chars_result to_chars(char* first, char* last, double value); diff --git a/contrib/libs/cxxsupp/libcxx/include/chrono b/contrib/libs/cxxsupp/libcxx/include/chrono index db186a4fba..c36c8f9e72 100644 --- a/contrib/libs/cxxsupp/libcxx/include/chrono +++ b/contrib/libs/cxxsupp/libcxx/include/chrono @@ -148,11 +148,6 @@ template <class Clock, class Duration1, class Duration2> namespace chrono { - -template<class T> struct is_clock; // C++20 -template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20 - - // duration arithmetic template <class Rep1, class Period1, class Rep2, class Period2> constexpr @@ -281,19 +276,23 @@ template <class Duration> using sys_seconds = sys_time<seconds>; // C++20 using sys_days = sys_time<days>; // C++20 -class utc_clock; // C++20 - -template <class Duration> - using utc_time = time_point<utc_clock, Duration>; // C++20 -using utc_seconds = utc_time<seconds>; // C++20 +class file_clock // C++20 +{ +public: + typedef see-below rep; + typedef nano period; + typedef chrono::duration<rep, period> duration; + typedef chrono::time_point<file_clock> time_point; + static constexpr bool is_steady = false; -class tai_clock; // C++20 + static time_point now() noexcept; -template <class Duration> - using tai_time = time_point<tai_clock, Duration>; // C++20 -using tai_seconds = tai_time<seconds>; // C++20 + template<class Duration> + static sys_time<see-below> to_sys(const file_time<Duration>&); -class file_clock; // C++20 + template<class Duration> + static file_time<see-below> from_sys(const sys_time<Duration>&); +}; template<class Duration> using file_time = time_point<file_clock, Duration>; // C++20 @@ -319,12 +318,6 @@ template<class Duration> using local_seconds = local_time<seconds>; using local_days = local_time<days>; -// 25.7.9, time_point conversions template<class DestClock, class SourceClock> // C++20 -struct clock_time_conversion; - -template<class DestClock, class SourceClock, class Duration> - auto clock_cast(const time_point<SourceClock, Duration>& t); - // 25.8.2, class last_spec // C++20 struct last_spec; @@ -639,39 +632,12 @@ public: constexpr precision to_duration() const noexcept; }; -template <class charT, class traits, class Duration> - basic_ostream<charT, traits>& - operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms); - // 26.10, 12/24 hour functions constexpr bool is_am(hours const& h) noexcept; constexpr bool is_pm(hours const& h) noexcept; constexpr hours make12(const hours& h) noexcept; constexpr hours make24(const hours& h, bool is_pm) noexcept; - -// 25.10.2, time zone database // C++20 -struct tzdb; -class tzdb_list; - -// 25.10.2.3, time zone database access // C++20 -const tzdb& get_tzdb(); -tzdb_list& get_tzdb_list(); -const time_zone* locate_zone(string_view tz_name); -const time_zone* current_zone(); - -// 25.10.2.4, remote time zone database support // C++20 -const tzdb& reload_tzdb(); -string remote_version(); - -// 25.10.3, exception classes // C++20 -class nonexistent_local_time; -class ambiguous_local_time; - -// 25.10.4, information classes // C++20 -struct sys_info; -struct local_info; - // 25.10.5, class time_zone // C++20 enum class choose {earliest, latest}; class time_zone; @@ -682,101 +648,6 @@ bool operator>(const time_zone& x, const time_zone& y) noexcept; bool operator<=(const time_zone& x, const time_zone& y) noexcept; bool operator>=(const time_zone& x, const time_zone& y) noexcept; -// 25.10.6, class template zoned_traits // C++20 -template<class T> struct zoned_traits; - -// 25.10.7, class template zoned_time // C++20 -template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time; -using zoned_seconds = zoned_time<seconds>; - -template<class Duration1, class Duration2, class TimeZonePtr> - bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, - const zoned_time<Duration2, TimeZonePtr>& y); -template<class Duration1, class Duration2, class TimeZonePtr> - bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x, - const zoned_time<Duration2, TimeZonePtr>& y); - -// 25.10.8, leap second support // C++20 -class leap; - -bool operator==(const leap& x, const leap& y); -bool operator!=(const leap& x, const leap& y); -bool operator< (const leap& x, const leap& y); -bool operator> (const leap& x, const leap& y); -bool operator<=(const leap& x, const leap& y); -bool operator>=(const leap& x, const leap& y); -template<class Duration> - bool operator==(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator==(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator!=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator!=(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator< (const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator< (const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator> (const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator> (const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator<=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator<=(const sys_time<Duration>& x, const leap& y); -template<class Duration> - bool operator>=(const leap& x, const sys_time<Duration>& y); -template<class Duration> - bool operator>=(const sys_time<Duration>& x, const leap& y); - -// 25.10.9, class link // C++20 -class link; -bool operator==(const link& x, const link& y); -bool operator!=(const link& x, const link& y); -bool operator< (const link& x, const link& y); -bool operator> (const link& x, const link& y); -bool operator<=(const link& x, const link& y); -bool operator>=(const link& x, const link& y); - -// 25.11, formatting // C++20 -template<class charT, class Streamable> - basic_string<charT> - format(const charT* fmt, const Streamable& s); - -template<class charT, class Streamable> - basic_string<charT> - format(const locale& loc, const charT* fmt, const Streamable& s); - -template<class charT, class traits, class Alloc, class Streamable> - basic_string<charT, traits, Alloc> - format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s); - -template<class charT, class traits, class Alloc, class Streamable> - basic_string<charT, traits, Alloc> - format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt, - const Streamable& s); - -// 25.12, parsing // C++20 -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - basic_string<charT, traits, Alloc>& abbrev); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - minutes& offset); - -template<class charT, class traits, class Alloc, class Parsable> -unspecified - parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, - basic_string<charT, traits, Alloc>& abbrev, minutes& offset); - // calendrical constants inline constexpr last_spec last{}; // C++20 inline constexpr chrono::weekday Sunday{0}; // C++20 @@ -1844,6 +1715,7 @@ class weekday_last; class weekday { private: unsigned char __wd; + static constexpr unsigned char __weekday_from_days(int __days) noexcept; public: weekday() = default; inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} @@ -1863,9 +1735,6 @@ public: inline constexpr bool ok() const noexcept { return __wd <= 6; } constexpr weekday_indexed operator[](unsigned __index) const noexcept; constexpr weekday_last operator[](last_spec) const noexcept; - - // TODO: Make private? - static constexpr unsigned char __weekday_from_days(int __days) noexcept; }; @@ -2956,18 +2825,19 @@ struct _FilesystemClock { _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; - _LIBCPP_INLINE_VISIBILITY - static time_t to_time_t(const time_point& __t) noexcept { - typedef chrono::duration<rep> __secs; - return time_t( - chrono::duration_cast<__secs>(__t.time_since_epoch()).count()); +#if _LIBCPP_STD_VER > 17 + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI + static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { + return chrono::sys_time<_Duration>(__t.time_since_epoch()); } - _LIBCPP_INLINE_VISIBILITY - static time_point from_time_t(time_t __t) noexcept { - typedef chrono::duration<rep> __secs; - return time_point(__secs(__t)); + template <class _Duration> + _LIBCPP_HIDE_FROM_ABI + static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) { + return chrono::file_time<_Duration>(__t.time_since_epoch()); } +#endif // _LIBCPP_STD_VER > 17 }; _LIBCPP_END_NAMESPACE_FILESYSTEM #endif // !_LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex index e4c59193bc..e6443791f3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/complex +++ b/contrib/libs/cxxsupp/libcxx/include/complex @@ -1056,6 +1056,9 @@ complex<_Tp> exp(const complex<_Tp>& __x) { _Tp __i = __x.imag(); + if (__i == 0) { + return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag())); + } if (__libcpp_isinf_or_builtin(__x.real())) { if (__x.real() < _Tp(0)) @@ -1070,8 +1073,6 @@ exp(const complex<_Tp>& __x) return complex<_Tp>(__x.real(), __i); } } - else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) - return __x; _Tp __e = exp(__x.real()); return complex<_Tp>(__e * cos(__i), __e * sin(__i)); } @@ -1269,8 +1270,8 @@ tanh(const complex<_Tp>& __x) if (__libcpp_isinf_or_builtin(__x.real())) { if (!__libcpp_isfinite_or_builtin(__x.imag())) - return complex<_Tp>(_Tp(1), _Tp(0)); - return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); + return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0)); + return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); } if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) return __x; diff --git a/contrib/libs/cxxsupp/libcxx/include/deque b/contrib/libs/cxxsupp/libcxx/include/deque index 67cd6654f1..dd47fb124d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/deque +++ b/contrib/libs/cxxsupp/libcxx/include/deque @@ -129,7 +129,7 @@ public: template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> deque(InputIterator, InputIterator, Allocator = Allocator()) - -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>; + -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 template <class T, class Allocator> bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y); @@ -162,6 +162,7 @@ template <class T, class Allocator, class Predicate> #include <__config> #include <__debug> +#include <__iterator/iterator_traits.h> #include <__split_buffer> #include <__utility/forward.h> #include <algorithm> @@ -1260,20 +1261,20 @@ public: static_assert((is_same<typename allocator_type::value_type, value_type>::value), "Allocator::value_type must be same type as value_type"); - typedef __deque_base<value_type, allocator_type> __base; + typedef __deque_base<value_type, allocator_type> __base; - typedef typename __base::__alloc_traits __alloc_traits; - typedef typename __base::reference reference; - typedef typename __base::const_reference const_reference; - typedef typename __base::iterator iterator; - typedef typename __base::const_iterator const_iterator; - typedef typename __base::size_type size_type; - typedef typename __base::difference_type difference_type; + typedef typename __base::__alloc_traits __alloc_traits; + typedef typename __base::reference reference; + typedef typename __base::const_reference const_reference; + typedef typename __base::iterator iterator; + typedef typename __base::const_iterator const_iterator; + typedef typename __allocator_traits<allocator_type>::size_type size_type; + typedef typename __base::difference_type difference_type; - typedef typename __base::pointer pointer; - typedef typename __base::const_pointer const_pointer; - typedef _VSTD::reverse_iterator<iterator> reverse_iterator; - typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; + typedef typename __base::pointer pointer; + typedef typename __base::const_pointer const_pointer; + typedef _VSTD::reverse_iterator<iterator> reverse_iterator; + typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; using typename __base::__deque_range; using typename __base::__deque_block_range; @@ -1570,6 +1571,7 @@ public: #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > deque(_InputIterator, _InputIterator) @@ -1577,13 +1579,13 @@ deque(_InputIterator, _InputIterator) template<class _InputIterator, class _Alloc, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>; #endif - template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(size_type __n) { diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource b/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource index 816d21f513..75e502d78c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/memory_resource @@ -183,11 +183,8 @@ public: // 8.6.3, memory.polymorphic.allocator.mem _LIBCPP_INLINE_VISIBILITY _ValueType* allocate(size_t __n) { - if (__n > __max_size()) { - __throw_length_error( - "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" - " 'n' exceeds maximum supported size"); - } + if (__n > __max_size()) + __throw_bad_array_new_length(); return static_cast<_ValueType*>( __res_->allocate(__n * sizeof(_ValueType), _LIBCPP_ALIGNOF(_ValueType)) ); @@ -384,11 +381,8 @@ public: private: virtual void * do_allocate(size_t __bytes, size_t) { - if (__bytes > __max_size()) { - __throw_length_error( - "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" - " 'bytes' exceeds maximum supported size"); - } + if (__bytes > __max_size()) + __throw_bad_array_new_length(); size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; return __alloc_.allocate(__s); } diff --git a/contrib/libs/cxxsupp/libcxx/include/filesystem b/contrib/libs/cxxsupp/libcxx/include/filesystem index f503343f87..8c75d88c87 100644 --- a/contrib/libs/cxxsupp/libcxx/include/filesystem +++ b/contrib/libs/cxxsupp/libcxx/include/filesystem @@ -11,7 +11,7 @@ /* filesystem synopsis - namespace std { namespace filesystem { + namespace std::filesystem { class path; @@ -48,13 +48,13 @@ // enable directory_iterator range-based for statements directory_iterator begin(directory_iterator iter) noexcept; - directory_iterator end(const directory_iterator&) noexcept; + directory_iterator end(directory_iterator) noexcept; class recursive_directory_iterator; // enable recursive_directory_iterator range-based for statements recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; - recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; + recursive_directory_iterator end(recursive_directory_iterator) noexcept; class file_status; @@ -224,14 +224,25 @@ path weakly_canonical(path const& p); path weakly_canonical(path const& p, error_code& ec); +} // namespace std::filesystem -} } // namespaces std::filesystem +template <> +inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; +template <> +inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; + +template <> +inline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; +template <> +inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; */ #include <__availability> #include <__config> #include <__debug> +#include <__ranges/enable_borrowed_range.h> +#include <__ranges/enable_view.h> #include <__utility/forward.h> #include <chrono> #include <compare> @@ -961,6 +972,7 @@ public: _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); } +/* #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) // TODO Implement locale conversions. template <class _Source, class = _EnableIfPathable<_Source, void> > @@ -969,6 +981,7 @@ public: path(_InputIt __first, _InputIt _last, const locale& __loc, format = format::auto_format); #endif +*/ _LIBCPP_INLINE_VISIBILITY ~path() = default; @@ -2875,7 +2888,7 @@ begin(directory_iterator __iter) noexcept { } inline _LIBCPP_INLINE_VISIBILITY directory_iterator -end(const directory_iterator&) noexcept { +end(directory_iterator) noexcept { return directory_iterator(); } @@ -3007,7 +3020,7 @@ begin(recursive_directory_iterator __iter) noexcept { } inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator -end(const recursive_directory_iterator&) noexcept { +end(recursive_directory_iterator) noexcept { return recursive_directory_iterator(); } @@ -3015,6 +3028,18 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP _LIBCPP_END_NAMESPACE_FILESYSTEM +#if !defined(_LIBCPP_HAS_NO_RANGES) +template <> +inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::directory_iterator> = true; +template <> +inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::recursive_directory_iterator> = true; + +template <> +inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true; +template <> +inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true; +#endif + #endif // !_LIBCPP_CXX03_LANG #ifdef _LIBCPP_COMPILER_MSVC diff --git a/contrib/libs/cxxsupp/libcxx/include/forward_list b/contrib/libs/cxxsupp/libcxx/include/forward_list index 3454a784a1..41059a5878 100644 --- a/contrib/libs/cxxsupp/libcxx/include/forward_list +++ b/contrib/libs/cxxsupp/libcxx/include/forward_list @@ -647,7 +647,7 @@ public: typedef const value_type& const_reference; typedef typename allocator_traits<allocator_type>::pointer pointer; typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; - typedef typename allocator_traits<allocator_type>::size_type size_type; + typedef typename __allocator_traits<allocator_type>::size_type size_type; typedef typename allocator_traits<allocator_type>::difference_type difference_type; typedef typename base::iterator iterator; @@ -873,6 +873,7 @@ private: #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > forward_list(_InputIterator, _InputIterator) @@ -880,6 +881,7 @@ forward_list(_InputIterator, _InputIterator) template<class _InputIterator, class _Alloc, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > forward_list(_InputIterator, _InputIterator, _Alloc) @@ -1585,7 +1587,7 @@ template <class _Compare> void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { - if (this != &__x) + if (this != _VSTD::addressof(__x)) { base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_, __x.__before_begin()->__next_, diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list index 71406c6743..54bc5902f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/list +++ b/contrib/libs/cxxsupp/libcxx/include/list @@ -470,9 +470,9 @@ public: _LIBCPP_INLINE_VISIBILITY __list_const_iterator& operator=(const __list_const_iterator& __p) { - if (this != &__p) + if (this != _VSTD::addressof(__p)) { - __get_db()->__iterator_copy(this, &__p); + __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); __ptr_ = __p.__ptr_; } return *this; @@ -797,7 +797,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) #if _LIBCPP_DEBUG_LEVEL == 2 __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); - __c_node* __cn2 = __db->__find_c(&__c); + __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); _VSTD::swap(__cn1->beg_, __cn2->beg_); _VSTD::swap(__cn1->end_, __cn2->end_); _VSTD::swap(__cn1->cap_, __cn2->cap_); @@ -845,24 +845,24 @@ class _LIBCPP_TEMPLATE_VIS list typedef typename base::__link_pointer __link_pointer; public: - typedef _Tp value_type; - typedef _Alloc allocator_type; + typedef _Tp value_type; + typedef _Alloc allocator_type; static_assert((is_same<value_type, typename allocator_type::value_type>::value), "Invalid allocator::value_type"); - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::iterator iterator; - typedef typename base::const_iterator const_iterator; - typedef _VSTD::reverse_iterator<iterator> reverse_iterator; - typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename __allocator_traits<allocator_type>::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::iterator iterator; + typedef typename base::const_iterator const_iterator; + typedef _VSTD::reverse_iterator<iterator> reverse_iterator; + typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; #if _LIBCPP_STD_VER > 17 - typedef size_type __remove_return_type; + typedef size_type __remove_return_type; #else - typedef void __remove_return_type; + typedef void __remove_return_type; #endif _LIBCPP_INLINE_VISIBILITY @@ -1144,6 +1144,7 @@ private: #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > list(_InputIterator, _InputIterator) @@ -1151,6 +1152,7 @@ list(_InputIterator, _InputIterator) template<class _InputIterator, class _Alloc, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > list(_InputIterator, _InputIterator, _Alloc) @@ -1449,7 +1451,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::insert(iterator, x) called with an iterator not" " referring to this list"); #endif @@ -1470,7 +1472,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::insert(iterator, n, x) called with an iterator not" " referring to this list"); iterator __r(__p.__ptr_, this); @@ -1695,7 +1697,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::emplace(iterator, args...) called with an iterator not" " referring to this list"); #endif @@ -1718,7 +1720,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::insert(iterator, x) called with an iterator not" " referring to this list"); #endif @@ -1801,7 +1803,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::erase(iterator) called with an iterator not" " referring to this list"); #endif @@ -2004,10 +2006,10 @@ template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { - _LIBCPP_ASSERT(this != &__c, + _LIBCPP_ASSERT(this != _VSTD::addressof(__c), "list::splice(iterator, list) called with this == &list"); #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::splice(iterator, list) called with an iterator not" " referring to this list"); #endif @@ -2020,10 +2022,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) base::__sz() += __c.__sz(); __c.__sz() = 0; #if _LIBCPP_DEBUG_LEVEL == 2 - if (&__c != this) { + if (_VSTD::addressof(__c) != this) { __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); - __c_node* __cn2 = __db->__find_c(&__c); + __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) { --__ip; @@ -2047,13 +2049,13 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::splice(iterator, list, iterator) called with the first iterator" " not referring to this list"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__i) == &__c, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__i)) == _VSTD::addressof(__c), "list::splice(iterator, list, iterator) called with the second iterator" " not referring to the list argument"); - _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i), + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(_VSTD::addressof(__i)), "list::splice(iterator, list, iterator) called with the second iterator" " not dereferenceable"); #endif @@ -2065,10 +2067,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) --__c.__sz(); ++base::__sz(); #if _LIBCPP_DEBUG_LEVEL == 2 - if (&__c != this) { + if (_VSTD::addressof(__c) != this) { __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); - __c_node* __cn2 = __db->__find_c(&__c); + __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) { --__ip; @@ -2092,16 +2094,16 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, "list::splice(iterator, list, iterator, iterator) called with first iterator not" " referring to this list"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == &__c, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__f)) == _VSTD::addressof(__c), "list::splice(iterator, list, iterator, iterator) called with second iterator not" " referring to the list argument"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == &__c, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c), "list::splice(iterator, list, iterator, iterator) called with third iterator not" " referring to the list argument"); - if (this == &__c) + if (this == _VSTD::addressof(__c)) { for (const_iterator __i = __f; __i != __l; ++__i) _LIBCPP_ASSERT(__i != __p, @@ -2115,7 +2117,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con __link_pointer __first = __f.__ptr_; --__l; __link_pointer __last = __l.__ptr_; - if (this != &__c) + if (this != _VSTD::addressof(__c)) { size_type __s = _VSTD::distance(__f, __l) + 1; __c.__sz() -= __s; @@ -2124,10 +2126,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con base::__unlink_nodes(__first, __last); __link_nodes(__p.__ptr_, __first, __last); #if _LIBCPP_DEBUG_LEVEL == 2 - if (&__c != this) { + if (_VSTD::addressof(__c) != this) { __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); - __c_node* __cn2 = __db->__find_c(&__c); + __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) { --__ip; @@ -2263,7 +2265,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) #if _LIBCPP_DEBUG_LEVEL == 2 __libcpp_db* __db = __get_db(); __c_node* __cn1 = __db->__find_c_and_lock(this); - __c_node* __cn2 = __db->__find_c(&__c); + __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;) { --__p; diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale index 242790a9d4..549b0af25b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale +++ b/contrib/libs/cxxsupp/libcxx/include/locale @@ -1360,6 +1360,18 @@ protected: long double __v) const; virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const; + + template <class _Integral> + _LIBCPP_HIDE_FROM_ABI inline + _OutputIterator __do_put_integral(iter_type __s, ios_base& __iob, + char_type __fl, _Integral __v, + char const* __len) const; + + template <class _Float> + _LIBCPP_HIDE_FROM_ABI inline + _OutputIterator __do_put_floating_point(iter_type __s, ios_base& __iob, + char_type __fl, _Float __v, + char const* __len) const; }; template <class _CharT, class _OutputIterator> @@ -1456,22 +1468,32 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, } template <class _CharT, class _OutputIterator> +template <class _Integral> +_LIBCPP_HIDE_FROM_ABI inline _OutputIterator -num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, - char_type __fl, long __v) const +num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __iob, + char_type __fl, _Integral __v, + char const* __len) const { // Stage 1 - Get number in narrow char - char __fmt[6] = {'%', 0}; - const char* __len = "l"; - this->__format_int(__fmt+1, __len, true, __iob.flags()); + char __fmt[8] = {'%', 0}; + this->__format_int(__fmt+1, __len, is_signed<_Integral>::value, __iob.flags()); // Worst case is octal, with showbase enabled. Note that octal is always // printed as an unsigned value. + using _Unsigned = typename make_unsigned<_Integral>::type; _LIBCPP_CONSTEXPR const unsigned __nbuf - = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits - + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up + = (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits + + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up + 2; // base prefix + terminating null character // terminating null character char __nar[__nbuf]; +#ifdef _LIBCPP_COMPILER_CLANG_BASED +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); +#ifdef _LIBCPP_COMPILER_CLANG_BASED +#pragma clang diagnostic pop +#endif char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators @@ -1487,30 +1509,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, template <class _CharT, class _OutputIterator> _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, + char_type __fl, long __v) const +{ + return this->__do_put_integral(__s, __iob, __fl, __v, "l"); +} + +template <class _CharT, class _OutputIterator> +_OutputIterator +num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const { - // Stage 1 - Get number in narrow char - char __fmt[8] = {'%', 0}; - const char* __len = "ll"; - this->__format_int(__fmt+1, __len, true, __iob.flags()); - // Worst case is octal, with showbase enabled. Note that octal is always - // printed as an unsigned value. - _LIBCPP_CONSTEXPR const unsigned __nbuf - = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits - + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up - + 2; // base prefix + terminating null character // terminating null character - char __nar[__nbuf]; - int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); - char* __ne = __nar + __nc; - char* __np = this->__identify_padding(__nar, __ne, __iob); - // Stage 2 - Widen __nar while adding thousands separators - char_type __o[2*(__nbuf-1) - 1]; - char_type* __op; // pad here - char_type* __oe; // end of output - this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); - // [__o, __oe) contains thousands_sep'd wide number - // Stage 3 & 4 - return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); + return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); } template <class _CharT, class _OutputIterator> @@ -1518,27 +1527,7 @@ _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const { - // Stage 1 - Get number in narrow char - char __fmt[6] = {'%', 0}; - const char* __len = "l"; - this->__format_int(__fmt+1, __len, false, __iob.flags()); - // Worst case is octal, with showbase enabled. - _LIBCPP_CONSTEXPR const unsigned __nbuf - = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits - + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up - + 2; // base prefix + terminating null character - char __nar[__nbuf]; - int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); - char* __ne = __nar + __nc; - char* __np = this->__identify_padding(__nar, __ne, __iob); - // Stage 2 - Widen __nar while adding thousands separators - char_type __o[2*(__nbuf-1) - 1]; - char_type* __op; // pad here - char_type* __oe; // end of output - this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); - // [__o, __oe) contains thousands_sep'd wide number - // Stage 3 & 4 - return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); + return this->__do_put_integral(__s, __iob, __fl, __v, "l"); } template <class _CharT, class _OutputIterator> @@ -1546,42 +1535,28 @@ _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const { - // Stage 1 - Get number in narrow char - char __fmt[8] = {'%', 0}; - const char* __len = "ll"; - this->__format_int(__fmt+1, __len, false, __iob.flags()); - // Worst case is octal, with showbase enabled. - _LIBCPP_CONSTEXPR const unsigned __nbuf - = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits - + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up - + 2; // base prefix + terminating null character - char __nar[__nbuf]; - int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); - char* __ne = __nar + __nc; - char* __np = this->__identify_padding(__nar, __ne, __iob); - // Stage 2 - Widen __nar while adding thousands separators - char_type __o[2*(__nbuf-1) - 1]; - char_type* __op; // pad here - char_type* __oe; // end of output - this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); - // [__o, __oe) contains thousands_sep'd wide number - // Stage 3 & 4 - return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); + return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); } template <class _CharT, class _OutputIterator> +template <class _Float> +_LIBCPP_HIDE_FROM_ABI inline _OutputIterator -num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, - char_type __fl, double __v) const +num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_base& __iob, + char_type __fl, _Float __v, + char const* __len) const { // Stage 1 - Get number in narrow char char __fmt[8] = {'%', 0}; - const char* __len = ""; bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); const unsigned __nbuf = 30; char __nar[__nbuf]; char* __nb = __nar; int __nc; +#ifdef _LIBCPP_COMPILER_CLANG_BASED +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif if (__specify_precision) __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); @@ -1598,6 +1573,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, __throw_bad_alloc(); __nbh.reset(__nb); } +#ifdef _LIBCPP_COMPILER_CLANG_BASED +#pragma clang diagnostic pop +#endif char* __ne = __nb + __nc; char* __np = this->__identify_padding(__nb, __ne, __iob); // Stage 2 - Widen __nar while adding thousands separators @@ -1623,52 +1601,17 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, template <class _CharT, class _OutputIterator> _OutputIterator num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, + char_type __fl, double __v) const +{ + return this->__do_put_floating_point(__s, __iob, __fl, __v, ""); +} + +template <class _CharT, class _OutputIterator> +_OutputIterator +num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const { - // Stage 1 - Get number in narrow char - char __fmt[8] = {'%', 0}; - const char* __len = "L"; - bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); - const unsigned __nbuf = 30; - char __nar[__nbuf]; - char* __nb = __nar; - int __nc; - if (__specify_precision) - __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, - (int)__iob.precision(), __v); - else - __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); - unique_ptr<char, void(*)(void*)> __nbh(nullptr, free); - if (__nc > static_cast<int>(__nbuf-1)) - { - if (__specify_precision) - __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); - else - __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); - if (__nc == -1) - __throw_bad_alloc(); - __nbh.reset(__nb); - } - char* __ne = __nb + __nc; - char* __np = this->__identify_padding(__nb, __ne, __iob); - // Stage 2 - Widen __nar while adding thousands separators - char_type __o[2*(__nbuf-1) - 1]; - char_type* __ob = __o; - unique_ptr<char_type, void(*)(void*)> __obh(0, free); - if (__nb != __nar) - { - __ob = (char_type*)malloc(2*static_cast<size_t>(__nc)*sizeof(char_type)); - if (__ob == 0) - __throw_bad_alloc(); - __obh.reset(__ob); - } - char_type* __op; // pad here - char_type* __oe; // end of output - this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); - // [__o, __oe) contains thousands_sep'd wide number - // Stage 3 & 4 - __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl); - return __s; + return this->__do_put_floating_point(__s, __iob, __fl, __v, "L"); } template <class _CharT, class _OutputIterator> @@ -1677,10 +1620,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const { // Stage 1 - Get pointer in narrow char - char __fmt[6] = "%p"; const unsigned __nbuf = 20; char __nar[__nbuf]; - int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); + int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); char* __ne = __nar + __nc; char* __np = this->__identify_padding(__nar, __ne, __iob); // Stage 2 - Widen __nar @@ -2978,51 +2920,31 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, } break; case money_base::sign: - if (__psn.size() + __nsn.size() > 0) + if (__psn.size() > 0 && *__b == __psn[0]) { - if (__psn.size() == 0 || __nsn.size() == 0) - { // sign is optional - if (__psn.size() > 0) - { // __nsn.size() == 0 - if (*__b == __psn[0]) - { - ++__b; - if (__psn.size() > 1) - __trailing_sign = &__psn; - } - else - __neg = true; - } - else if (*__b == __nsn[0]) // __nsn.size() > 0 && __psn.size() == 0 - { - ++__b; - __neg = true; - if (__nsn.size() > 1) - __trailing_sign = &__nsn; - } - } - else // sign is required - { - if (*__b == __psn[0]) - { - ++__b; - if (__psn.size() > 1) - __trailing_sign = &__psn; - } - else if (*__b == __nsn[0]) - { - ++__b; - __neg = true; - if (__nsn.size() > 1) - __trailing_sign = &__nsn; - } - else - { - __err |= ios_base::failbit; - return false; - } - } + ++__b; + __neg = false; + if (__psn.size() > 1) + __trailing_sign = &__psn; + break; + } + if (__nsn.size() > 0 && *__b == __nsn[0]) + { + ++__b; + __neg = true; + if (__nsn.size() > 1) + __trailing_sign = &__nsn; + break; } + if (__psn.size() > 0 && __nsn.size() > 0) + { // sign is required + __err |= ios_base::failbit; + return false; + } + if (__psn.size() == 0 && __nsn.size() == 0) + // locale has no way of specifying a sign. Use the initial value of __neg as a default + break; + __neg = (__nsn.size() == 0); break; case money_base::symbol: { diff --git a/contrib/libs/cxxsupp/libcxx/include/map b/contrib/libs/cxxsupp/libcxx/include/map index c78a7ee31a..7f060d0a89 100644 --- a/contrib/libs/cxxsupp/libcxx/include/map +++ b/contrib/libs/cxxsupp/libcxx/include/map @@ -223,6 +223,25 @@ public: pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; +template <class InputIterator, + class Compare = less<iter_key_t<InputIterator>>, + class Allocator = allocator<iter_to_alloc_t<InputIterator>>> +map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) + -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 + +template<class Key, class T, class Compare = less<Key>, + class Allocator = allocator<pair<const Key, T>>> +map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) + -> map<Key, T, Compare, Allocator>; // C++17 + +template <class InputIterator, class Allocator> +map(InputIterator, InputIterator, Allocator) + -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>, + Allocator>; // C++17 + +template<class Key, class T, class Allocator> +map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17 + template <class Key, class T, class Compare, class Allocator> bool operator==(const map<Key, T, Compare, Allocator>& x, @@ -444,6 +463,26 @@ public: pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; +template <class InputIterator, + class Compare = less<iter_key_t<InputIterator>>, + class Allocator = allocator<iter_to_alloc_t<InputIterator>>> +multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) + -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 + +template<class Key, class T, class Compare = less<Key>, + class Allocator = allocator<pair<const Key, T>>> +multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) + -> multimap<Key, T, Compare, Allocator>; // C++17 + +template <class InputIterator, class Allocator> +multimap(InputIterator, InputIterator, Allocator) + -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, + less<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class Key, class T, class Allocator> +multimap(initializer_list<pair<const Key, T>>, Allocator) + -> multimap<Key, T, less<Key>, Allocator>; // C++17 + template <class Key, class T, class Compare, class Allocator> bool operator==(const multimap<Key, T, Compare, Allocator>& x, @@ -492,6 +531,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 #include <__config> #include <__debug> #include <__functional/is_transparent.h> +#include <__iterator/iterator_traits.h> #include <__node_handle> #include <__tree> #include <__utility/forward.h> @@ -1501,6 +1541,7 @@ private: #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<!__is_allocator<_Compare>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) @@ -1514,6 +1555,7 @@ map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allo -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> map(_InputIterator, _InputIterator, _Allocator) -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, @@ -2174,6 +2216,7 @@ private: #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<!__is_allocator<_Compare>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) @@ -2187,6 +2230,7 @@ multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> multimap(_InputIterator, _InputIterator, _Allocator) -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, diff --git a/contrib/libs/cxxsupp/libcxx/include/memory b/contrib/libs/cxxsupp/libcxx/include/memory index 1975092ba0..7f6665e846 100644 --- a/contrib/libs/cxxsupp/libcxx/include/memory +++ b/contrib/libs/cxxsupp/libcxx/include/memory @@ -405,7 +405,8 @@ template<class T> class shared_ptr { public: - typedef T element_type; + typedef T element_type; // until C++17 + typedef remove_extent_t<T> element_type; // since C++17 typedef weak_ptr<T> weak_type; // C++17 // constructors: @@ -525,7 +526,8 @@ template<class T> class weak_ptr { public: - typedef T element_type; + typedef T element_type; // until C++17 + typedef remove_extent_t<T> element_type; // since C++17 // constructors constexpr weak_ptr() noexcept; @@ -653,14 +655,6 @@ template <class T> struct hash<shared_ptr<T> >; template <class T, class Alloc> inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; -// Pointer safety -enum class pointer_safety { relaxed, preferred, strict }; // since C++11 -void declare_reachable(void *p); // since C++11 -template <class T> T *undeclare_reachable(T *p); // since C++11 -void declare_no_pointers(char *p, size_t n); // since C++11 -void undeclare_no_pointers(char *p, size_t n); // since C++11 -pointer_safety get_pointer_safety() noexcept; // since C++11 - void* align(size_t alignment, size_t size, void*& ptr, size_t& space); } // std @@ -676,7 +670,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/construct_at.h> -#include <__memory/pointer_safety.h> #include <__memory/pointer_traits.h> #include <__memory/raw_storage_iterator.h> #include <__memory/shared_ptr.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/module.modulemap b/contrib/libs/cxxsupp/libcxx/include/module.modulemap index 80cdfe323f..2f96f9aa96 100644 --- a/contrib/libs/cxxsupp/libcxx/include/module.modulemap +++ b/contrib/libs/cxxsupp/libcxx/include/module.modulemap @@ -620,7 +620,6 @@ module std [system] { module auto_ptr { private header "__memory/auto_ptr.h" } module compressed_pair { private header "__memory/compressed_pair.h" } module construct_at { private header "__memory/construct_at.h" } - module pointer_safety { private header "__memory/pointer_safety.h" } module pointer_traits { private header "__memory/pointer_traits.h" } module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" } module shared_ptr { private header "__memory/shared_ptr.h" } diff --git a/contrib/libs/cxxsupp/libcxx/include/mutex b/contrib/libs/cxxsupp/libcxx/include/mutex index e815dda502..c96d7b14a8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/mutex +++ b/contrib/libs/cxxsupp/libcxx/include/mutex @@ -112,7 +112,7 @@ template <class... MutexTypes> class scoped_lock // C++17 { public: - using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex + using mutex_type = Mutex; // Only if sizeof...(MutexTypes) == 1 explicit scoped_lock(MutexTypes&... m); scoped_lock(adopt_lock_t, MutexTypes&... m); diff --git a/contrib/libs/cxxsupp/libcxx/include/new b/contrib/libs/cxxsupp/libcxx/include/new index 2d1417a975..711b3ccd22 100644 --- a/contrib/libs/cxxsupp/libcxx/include/new +++ b/contrib/libs/cxxsupp/libcxx/include/new @@ -149,6 +149,16 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec +_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY +void __throw_bad_array_new_length() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_new_length(); +#else + _VSTD::abort(); +#endif +} + #if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && \ !defined(_LIBCPP_ABI_VCRUNTIME) #ifndef _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/ostream b/contrib/libs/cxxsupp/libcxx/include/ostream index e0aa18fa48..1b3dd54799 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ostream +++ b/contrib/libs/cxxsupp/libcxx/include/ostream @@ -55,6 +55,7 @@ public: basic_ostream& operator<<(double f); basic_ostream& operator<<(long double f); basic_ostream& operator<<(const void* p); + basic_ostream& operator<<(const volatile void* val); // C++23 basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb); basic_ostream& operator<<(nullptr_t); @@ -210,6 +211,14 @@ public: basic_ostream& operator<<(double __f); basic_ostream& operator<<(long double __f); basic_ostream& operator<<(const void* __p); + +#if _LIBCPP_STD_VER > 20 + _LIBCPP_HIDE_FROM_ABI + basic_ostream& operator<<(const volatile void* __p) { + return operator<<(const_cast<const void*>(__p)); + } +#endif + basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/libs/cxxsupp/libcxx/include/queue b/contrib/libs/cxxsupp/libcxx/include/queue index cbd07140a7..2c5fa3237f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/queue +++ b/contrib/libs/cxxsupp/libcxx/include/queue @@ -185,16 +185,16 @@ template<class InputIterator, class Allocator> priority_queue(InputIterator, InputIterator, Allocator) -> priority_queue<iter-value-type<InputIterator>, vector<iter-value-type<InputIterator>, Allocator>, - less<iter-value-type<InputIterator>>>; + less<iter-value-type<InputIterator>>>; // C++17 template<class InputIterator, class Compare, class Allocator> priority_queue(InputIterator, InputIterator, Compare, Allocator) -> priority_queue<iter-value-type<InputIterator>, - vector<iter-value-type<InputIterator>, Allocator>, Compare>; + vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 template<class InputIterator, class Compare, class Container, class Allocator> priority_queue(InputIterator, InputIterator, Compare, Container, Allocator) - -> priority_queue<typename Container::value_type, Container, Compare>; + -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 template <class T, class Container, class Compare> void swap(priority_queue<T, Container, Compare>& x, diff --git a/contrib/libs/cxxsupp/libcxx/include/scoped_allocator b/contrib/libs/cxxsupp/libcxx/include/scoped_allocator index dc24d30b51..5c2aeb7cf7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/scoped_allocator +++ b/contrib/libs/cxxsupp/libcxx/include/scoped_allocator @@ -91,6 +91,10 @@ public: scoped_allocator_adaptor select_on_container_copy_construction() const noexcept; }; +template<class OuterAlloc, class... InnerAllocs> + scoped_allocator_adaptor(OuterAlloc, InnerAllocs...) + -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>; + template <class OuterA1, class OuterA2, class... InnerAllocs> bool operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, @@ -649,6 +653,12 @@ private: template <class...> friend class __scoped_allocator_storage; }; +#if _LIBCPP_STD_VER > 14 +template<class _OuterAlloc, class... _InnerAllocs> + scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) + -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; +#endif + template <class _OuterA1, class _OuterA2> inline _LIBCPP_INLINE_VISIBILITY bool diff --git a/contrib/libs/cxxsupp/libcxx/include/semaphore b/contrib/libs/cxxsupp/libcxx/include/semaphore index 4f9ecd0461..db03fb967e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/semaphore +++ b/contrib/libs/cxxsupp/libcxx/include/semaphore @@ -67,10 +67,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD /* -__atomic_semaphore_base is the general-case implementation, to be used for -user-requested least-max values that exceed the OS implementation support -(incl. when the OS has no support of its own) and for binary semaphores. - +__atomic_semaphore_base is the general-case implementation. It is a typical Dijkstra semaphore algorithm over atomics, wait and notify functions. It avoids contention against users' own use of those facilities. @@ -108,81 +105,30 @@ public: _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time) { - auto const __test_fn = [this]() -> bool { - auto __old = __a.load(memory_order_acquire); - while(1) { - if (__old == 0) - return false; - if(__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) - return true; - } - }; + if (__rel_time == chrono::duration<Rep, Period>::zero()) + return try_acquire(); + auto const __test_fn = [this]() { return try_acquire(); }; return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time); } -}; - -#ifndef _LIBCPP_NO_NATIVE_SEMAPHORES - -/* - -__platform_semaphore_base a simple wrapper for the OS semaphore type. That -is, every call is routed to the OS in the most direct manner possible. - -*/ - -class __platform_semaphore_base -{ - __libcpp_semaphore_t __semaphore; - -public: - _LIBCPP_INLINE_VISIBILITY - explicit __platform_semaphore_base(ptrdiff_t __count) : - __semaphore() - { - __libcpp_semaphore_init(&__semaphore, __count); - } - _LIBCPP_INLINE_VISIBILITY - ~__platform_semaphore_base() { - __libcpp_semaphore_destroy(&__semaphore); - } - _LIBCPP_INLINE_VISIBILITY - void release(ptrdiff_t __update) - { - for(; __update; --__update) - __libcpp_semaphore_post(&__semaphore); - } - _LIBCPP_INLINE_VISIBILITY - void acquire() - { - __libcpp_semaphore_wait(&__semaphore); - } - _LIBCPP_INLINE_VISIBILITY - bool try_acquire_for(chrono::nanoseconds __rel_time) + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY + bool try_acquire() { - return __libcpp_semaphore_wait_timed(&__semaphore, __rel_time); + auto __old = __a.load(memory_order_acquire); + while (true) { + if (__old == 0) + return false; + if (__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) + return true; + } } }; -template<ptrdiff_t __least_max_value> -using __semaphore_base = - typename conditional<(__least_max_value > 1 && __least_max_value <= _LIBCPP_SEMAPHORE_MAX), - __platform_semaphore_base, - __atomic_semaphore_base>::type; - -#else - -template<ptrdiff_t __least_max_value> -using __semaphore_base = - __atomic_semaphore_base; - #define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) -#endif //_LIBCPP_NO_NATIVE_SEMAPHORES - template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> class counting_semaphore { - __semaphore_base<__least_max_value> __semaphore; + __atomic_semaphore_base __semaphore; public: static constexpr ptrdiff_t max() noexcept { @@ -215,14 +161,14 @@ public: _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY bool try_acquire() { - return try_acquire_for(chrono::nanoseconds::zero()); + return __semaphore.try_acquire(); } template <class Clock, class Duration> _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time) { auto const current = Clock::now(); - if(current >= __abs_time) + if (current >= __abs_time) return try_acquire(); else return try_acquire_for(__abs_time - current); diff --git a/contrib/libs/cxxsupp/libcxx/include/set b/contrib/libs/cxxsupp/libcxx/include/set index 46b515ba53..1718a644d4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/set +++ b/contrib/libs/cxxsupp/libcxx/include/set @@ -183,6 +183,25 @@ public: pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; +template <class InputIterator, + class Compare = less<typename iterator_traits<InputIterator>::value_type>, + class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> +set(InputIterator, InputIterator, + Compare = Compare(), Allocator = Allocator()) + -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 + +template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> +set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) + -> set<Key, Compare, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +set(InputIterator, InputIterator, Allocator) + -> set<typename iterator_traits<InputIterator>::value_type, + less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 + +template<class Key, class Allocator> +set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17 + template <class Key, class Compare, class Allocator> bool operator==(const set<Key, Compare, Allocator>& x, @@ -389,6 +408,25 @@ public: pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; +template <class InputIterator, + class Compare = less<typename iterator_traits<InputIterator>::value_type>, + class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> +multiset(InputIterator, InputIterator, + Compare = Compare(), Allocator = Allocator()) + -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 + +template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> +multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) + -> multiset<Key, Compare, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +multiset(InputIterator, InputIterator, Allocator) + -> multiset<typename iterator_traits<InputIterator>::value_type, + less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 + +template<class Key, class Allocator> +multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17 + template <class Key, class Compare, class Allocator> bool operator==(const multiset<Key, Compare, Allocator>& x, @@ -436,6 +474,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 #include <__config> #include <__debug> #include <__functional/is_transparent.h> +#include <__iterator/iterator_traits.h> #include <__node_handle> #include <__tree> #include <__utility/forward.h> @@ -462,7 +501,7 @@ public: // types: typedef _Key key_type; typedef key_type value_type; - typedef _Compare key_compare; + typedef __identity_t<_Compare> key_compare; typedef key_compare value_compare; typedef __identity_t<_Allocator> allocator_type; typedef value_type& reference; @@ -474,7 +513,6 @@ public: private: typedef __tree<value_type, value_compare, allocator_type> __base; typedef allocator_traits<allocator_type> __alloc_traits; - typedef typename __base::__node_holder __node_holder; __base __tree_; @@ -872,6 +910,7 @@ public: template<class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>, class _Allocator = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>, class = enable_if_t<!__is_allocator<_Compare>::value, void>> set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) @@ -879,12 +918,13 @@ set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocat template<class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key>, - class = enable_if_t<__is_allocator<_Allocator>::value, void>, - class = enable_if_t<!__is_allocator<_Compare>::value, void>> + class = enable_if_t<!__is_allocator<_Compare>::value, void>, + class = enable_if_t<__is_allocator<_Allocator>::value, void>> set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) -> set<_Key, _Compare, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> set(_InputIterator, _InputIterator, _Allocator) -> set<__iter_value_type<_InputIterator>, @@ -992,9 +1032,9 @@ class _LIBCPP_TEMPLATE_VIS multiset { public: // types: - typedef _Key key_type; + typedef _Key key_type; typedef key_type value_type; - typedef _Compare key_compare; + typedef __identity_t<_Compare> key_compare; typedef key_compare value_compare; typedef __identity_t<_Allocator> allocator_type; typedef value_type& reference; @@ -1006,7 +1046,6 @@ public: private: typedef __tree<value_type, value_compare, allocator_type> __base; typedef allocator_traits<allocator_type> __alloc_traits; - typedef typename __base::__node_holder __node_holder; __base __tree_; @@ -1403,6 +1442,7 @@ public: template<class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>, class _Allocator = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>, class = enable_if_t<!__is_allocator<_Compare>::value, void>> multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) @@ -1416,6 +1456,7 @@ multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator( -> multiset<_Key, _Compare, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, class = enable_if_t<__is_allocator<_Allocator>::value, void>> multiset(_InputIterator, _InputIterator, _Allocator) -> multiset<__iter_value_type<_InputIterator>, diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span index 5d57bd693c..d10cb73805 100644 --- a/contrib/libs/cxxsupp/libcxx/include/span +++ b/contrib/libs/cxxsupp/libcxx/include/span @@ -61,7 +61,7 @@ public: template <class It, class End> constexpr explicit(Extent != dynamic_extent) span(It first, End last); template <size_t N> - constexpr span(element_type (&arr)[N]) noexcept; + constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept; template <size_t N> constexpr span(array<value_type, N>& arr) noexcept; template <size_t N> @@ -89,7 +89,7 @@ public: // [span.obs], span observers constexpr size_type size() const noexcept; constexpr size_type size_bytes() const noexcept; - constexpr bool empty() const noexcept; + [[nodiscard]] constexpr bool empty() const noexcept; // [span.elem], span element access constexpr reference operator[](size_type idx) const; @@ -264,7 +264,7 @@ public: { (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); } #endif - _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {} + _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {} template <class _OtherElementType, enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> @@ -374,9 +374,9 @@ public: return {data() + __offset, __count}; } - _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; } - _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); } - _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; } + _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; } + _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); } + [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; } _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept { @@ -469,7 +469,7 @@ public: template <size_t _Sz> _LIBCPP_INLINE_VISIBILITY - constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} + constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} template <class _OtherElementType, size_t _Sz, enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> @@ -560,9 +560,9 @@ public: return {data() + __offset, __count}; } - _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; } - _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); } - _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; } + _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; } + _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); } + [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; } _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept { diff --git a/contrib/libs/cxxsupp/libcxx/include/system_error b/contrib/libs/cxxsupp/libcxx/include/system_error index 7e6d3c1cc5..365f024ca6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/system_error +++ b/contrib/libs/cxxsupp/libcxx/include/system_error @@ -46,10 +46,10 @@ template <class T> struct is_error_condition_enum : public false_type {}; template <class _Tp> -inline constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 +inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 template <class _Tp> -inline constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 +inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 class error_code { @@ -165,7 +165,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_code_enum #if _LIBCPP_STD_VER > 14 template <class _Tp> -inline constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; +inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; #endif // is_error_condition_enum @@ -176,7 +176,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum #if _LIBCPP_STD_VER > 14 template <class _Tp> -inline constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; +inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; #endif template <> diff --git a/contrib/libs/cxxsupp/libcxx/include/type_traits b/contrib/libs/cxxsupp/libcxx/include/type_traits index 8c91522074..add71a380f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/type_traits +++ b/contrib/libs/cxxsupp/libcxx/include/type_traits @@ -879,9 +879,8 @@ inline constexpr bool is_array_v = is_array<_Tp>::value; // is_pointer -// Before Clang 11 / AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. +// Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. #if __has_keyword(__is_pointer) && \ - !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1100) && \ !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) && \ !defined(__CUDACC__) diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map index 417180a530..c6d4137b21 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_map +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map @@ -216,6 +216,47 @@ public: void reserve(size_type n); }; +template<class InputIterator, + class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, + class Allocator = allocator<iter_to_alloc_t<InputIterator>>> +unordered_map(InputIterator, InputIterator, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, + Allocator>; // C++17 + +template<class Key, class T, class Hash = hash<Key>, + class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> +unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator) + -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, + hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_map(InputIterator, InputIterator, Allocator) + -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, + hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class InputIterator, class Hash, class Allocator> +unordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) + -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, + equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class Key, class T, typename Allocator> +unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) + -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 + +template<class Key, class T, typename Allocator> +unordered_map(initializer_list<pair<const Key, T>>, Allocator) + -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 + +template<class Key, class T, class Hash, class Allocator> +unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator) + -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 + template <class Key, class T, class Hash, class Pred, class Alloc> void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, unordered_map<Key, T, Hash, Pred, Alloc>& y) @@ -404,6 +445,48 @@ public: void reserve(size_type n); }; +template<class InputIterator, + class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, + class Allocator = allocator<iter_to_alloc_t<InputIterator>>> +unordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, + Allocator>; // C++17 + +template<class Key, class T, class Hash = hash<Key>, + class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> +unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator) + -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, + hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_multimap(InputIterator, InputIterator, Allocator) + -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, + hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class InputIterator, class Hash, class Allocator> +unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) + -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, + equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 + +template<class Key, class T, typename Allocator> +unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) + -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 + +template<class Key, class T, typename Allocator> +unordered_multimap(initializer_list<pair<const Key, T>>, Allocator) + -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 + +template<class Key, class T, class Hash, class Allocator> +unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, + Allocator) + -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 + template <class Key, class T, class Hash, class Pred, class Alloc> void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, unordered_multimap<Key, T, Hash, Pred, Alloc>& y) @@ -434,6 +517,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <__config> #include <__debug> #include <__functional/is_transparent.h> +#include <__iterator/iterator_traits.h> #include <__hash_table> #include <__node_handle> #include <__utility/forward.h> @@ -1470,6 +1554,7 @@ template<class _InputIterator, class _Hash = hash<__iter_key_type<_InputIterator>>, class _Pred = equal_to<__iter_key_type<_InputIterator>>, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<!__is_allocator<_Pred>::value>, @@ -1490,18 +1575,21 @@ unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allo -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_map(_InputIterator, _InputIterator, _Allocator) -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; template<class _InputIterator, class _Hash, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> @@ -2268,6 +2356,7 @@ template<class _InputIterator, class _Hash = hash<__iter_key_type<_InputIterator>>, class _Pred = equal_to<__iter_key_type<_InputIterator>>, class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<!__is_allocator<_Pred>::value>, @@ -2288,18 +2377,21 @@ unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits< -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_multimap(_InputIterator, _InputIterator, _Allocator) -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; template<class _InputIterator, class _Hash, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set index 5856e4bc40..33b54d957f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_set +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set @@ -182,6 +182,43 @@ public: void reserve(size_type n); }; +template<class InputIterator, + class Hash = hash<typename iterator_traits<InputIterator>::value_type>, + class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, + class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> +unordered_set(InputIterator, InputIterator, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_set<typename iterator_traits<InputIterator>::value_type, + Hash, Pred, Allocator>; // C++17 + +template<class T, class Hash = hash<T>, + class Pred = equal_to<T>, class Allocator = allocator<T>> +unordered_set(initializer_list<T>, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_set<T, Hash, Pred, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator) + -> unordered_set<typename iterator_traits<InputIterator>::value_type, + hash<typename iterator_traits<InputIterator>::value_type>, + equal_to<typename iterator_traits<InputIterator>::value_type>, + Allocator>; // C++17 + +template<class InputIterator, class Hash, class Allocator> +unordered_set(InputIterator, InputIterator, typename see below::size_type, + Hash, Allocator) + -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash, + equal_to<typename iterator_traits<InputIterator>::value_type>, + Allocator>; // C++17 + +template<class T, class Allocator> +unordered_set(initializer_list<T>, typename see below::size_type, Allocator) + -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17 + +template<class T, class Hash, class Allocator> +unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator) + -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17 + template <class Value, class Hash, class Pred, class Alloc> void swap(unordered_set<Value, Hash, Pred, Alloc>& x, unordered_set<Value, Hash, Pred, Alloc>& y) @@ -359,6 +396,42 @@ public: void reserve(size_type n); }; +template<class InputIterator, + class Hash = hash<typename iterator_traits<InputIterator>::value_type>, + class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, + class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> +unordered_multiset(InputIterator, InputIterator, see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, + Hash, Pred, Allocator>; // C++17 + +template<class T, class Hash = hash<T>, + class Pred = equal_to<T>, class Allocator = allocator<T>> +unordered_multiset(initializer_list<T>, typename see below::size_type = see below, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17 + +template<class InputIterator, class Allocator> +unordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator) + -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, + hash<typename iterator_traits<InputIterator>::value_type>, + equal_to<typename iterator_traits<InputIterator>::value_type>, + Allocator>; // C++17 + +template<class InputIterator, class Hash, class Allocator> +unordered_multiset(InputIterator, InputIterator, typename see below::size_type, + Hash, Allocator) + -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash, + equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 + +template<class T, class Allocator> +unordered_multiset(initializer_list<T>, typename see below::size_type, Allocator) + -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17 + +template<class T, class Hash, class Allocator> +unordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator) + -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17 + template <class Value, class Hash, class Pred, class Alloc> void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x, unordered_multiset<Value, Hash, Pred, Alloc>& y) @@ -803,6 +876,7 @@ template<class _InputIterator, class _Hash = hash<__iter_value_type<_InputIterator>>, class _Pred = equal_to<__iter_value_type<_InputIterator>>, class _Allocator = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<!__is_allocator<_Pred>::value>, @@ -823,6 +897,7 @@ unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) @@ -832,6 +907,7 @@ unordered_set(_InputIterator, _InputIterator, _Allocator>; template<class _InputIterator, class _Hash, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> @@ -1468,6 +1544,7 @@ template<class _InputIterator, class _Hash = hash<__iter_value_type<_InputIterator>>, class _Pred = equal_to<__iter_value_type<_InputIterator>>, class _Allocator = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<!__is_allocator<_Pred>::value>, @@ -1487,6 +1564,7 @@ unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>: -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; template<class _InputIterator, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) -> unordered_multiset<__iter_value_type<_InputIterator>, @@ -1495,6 +1573,7 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al _Allocator>; template<class _InputIterator, class _Hash, class _Allocator, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<!__is_allocator<_Hash>::value>, class = enable_if_t<!is_integral<_Hash>::value>, class = enable_if_t<__is_allocator<_Allocator>::value>> diff --git a/contrib/libs/cxxsupp/libcxx/include/utility b/contrib/libs/cxxsupp/libcxx/include/utility index 7d021d9580..f8b954fc45 100644 --- a/contrib/libs/cxxsupp/libcxx/include/utility +++ b/contrib/libs/cxxsupp/libcxx/include/utility @@ -95,6 +95,8 @@ struct pair is_nothrow_swappable_v<T2>); // constexpr in C++20 }; +template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>; + template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 diff --git a/contrib/libs/cxxsupp/libcxx/include/valarray b/contrib/libs/cxxsupp/libcxx/include/valarray index 0a828885d2..2e895d59fd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/valarray +++ b/contrib/libs/cxxsupp/libcxx/include/valarray @@ -105,6 +105,8 @@ public: void resize(size_t n, value_type x = value_type()); }; +template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; + class slice { public: @@ -1081,6 +1083,11 @@ private: valarray& __assign_range(const value_type* __f, const value_type* __l); }; +#if _LIBCPP_STD_VER > 14 +template<class _Tp, size_t _Size> +valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; +#endif + _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) template <class _Op, class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index c02253c751..ce52a88570 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -245,7 +245,7 @@ public: template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> vector(InputIterator, InputIterator, Allocator = Allocator()) - -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; + -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 template <class Allocator> struct hash<std::vector<bool, Allocator>>; @@ -275,6 +275,7 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 #include <__bit_reference> #include <__debug> #include <__functional_base> +#include <__iterator/iterator_traits.h> #include <__iterator/wrap_iter.h> #include <__split_buffer> #include <__utility/forward.h> @@ -315,192 +316,60 @@ template <class _Tp, class _Allocator> class __vector_base : protected __vector_base_common<true> // This base class is historical, but it needs to remain for ABI compatibility { -public: - typedef _Allocator allocator_type; - typedef allocator_traits<allocator_type> __alloc_traits; - typedef typename __alloc_traits::size_type size_type; + typedef _Allocator allocator_type; + typedef typename allocator_traits<allocator_type>::pointer pointer; protected: - typedef _Tp value_type; - typedef value_type& reference; - typedef const value_type& const_reference; - typedef typename __alloc_traits::difference_type difference_type; - typedef typename __alloc_traits::pointer pointer; - typedef typename __alloc_traits::const_pointer const_pointer; - typedef pointer iterator; - typedef const_pointer const_iterator; - - pointer __begin_; - pointer __end_; - __compressed_pair<pointer, allocator_type> __end_cap_; - - _LIBCPP_INLINE_VISIBILITY - allocator_type& __alloc() _NOEXCEPT - {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY - const allocator_type& __alloc() const _NOEXCEPT - {return __end_cap_.second();} - _LIBCPP_INLINE_VISIBILITY - pointer& __end_cap() _NOEXCEPT - {return __end_cap_.first();} - _LIBCPP_INLINE_VISIBILITY - const pointer& __end_cap() const _NOEXCEPT - {return __end_cap_.first();} + pointer __begin_; + pointer __end_; + __compressed_pair<pointer, allocator_type> __end_cap_; _LIBCPP_INLINE_VISIBILITY __vector_base() - _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); - _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; -#endif - ~__vector_base(); + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, __default_init_tag()) {} - _LIBCPP_INLINE_VISIBILITY - void clear() _NOEXCEPT {__destruct_at_end(__begin_);} - _LIBCPP_INLINE_VISIBILITY - size_type capacity() const _NOEXCEPT - {return static_cast<size_type>(__end_cap() - __begin_);} - - _LIBCPP_INLINE_VISIBILITY - void __destruct_at_end(pointer __new_last) _NOEXCEPT; - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __vector_base& __c) - {__copy_assign_alloc(__c, integral_constant<bool, - __alloc_traits::propagate_on_container_copy_assignment::value>());} - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__vector_base& __c) - _NOEXCEPT_( - !__alloc_traits::propagate_on_container_move_assignment::value || - is_nothrow_move_assignable<allocator_type>::value) - {__move_assign_alloc(__c, integral_constant<bool, - __alloc_traits::propagate_on_container_move_assignment::value>());} - - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI - void __throw_length_error() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common<true>::__throw_length_error(); -#else - _VSTD::abort(); -#endif - } - - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI - void __throw_out_of_range() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common<true>::__throw_out_of_range(); -#else - _VSTD::abort(); -#endif - } - -private: - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __vector_base& __c, true_type) - { - if (__alloc() != __c.__alloc()) - { - clear(); - __alloc_traits::deallocate(__alloc(), __begin_, capacity()); - __begin_ = __end_ = __end_cap() = nullptr; - } - __alloc() = __c.__alloc(); - } - - _LIBCPP_INLINE_VISIBILITY - void __copy_assign_alloc(const __vector_base&, false_type) - {} - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__vector_base& __c, true_type) - _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) - { - __alloc() = _VSTD::move(__c.__alloc()); - } - - _LIBCPP_INLINE_VISIBILITY - void __move_assign_alloc(__vector_base&, false_type) - _NOEXCEPT - {} -}; - -template <class _Tp, class _Allocator> -inline _LIBCPP_INLINE_VISIBILITY -void -__vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT -{ - pointer __soon_to_be_end = __end_; - while (__new_last != __soon_to_be_end) - __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); - __end_ = __new_last; -} - -template <class _Tp, class _Allocator> -inline _LIBCPP_INLINE_VISIBILITY -__vector_base<_Tp, _Allocator>::__vector_base() - _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __default_init_tag()) -{ -} - -template <class _Tp, class _Allocator> -inline _LIBCPP_INLINE_VISIBILITY -__vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __a) -{ -} + _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a) + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, __a) {} #ifndef _LIBCPP_CXX03_LANG -template <class _Tp, class _Allocator> -inline _LIBCPP_INLINE_VISIBILITY -__vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, _VSTD::move(__a)) {} + _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT + : __begin_(nullptr), + __end_(nullptr), + __end_cap_(nullptr, _VSTD::move(__a)) {} #endif - -template <class _Tp, class _Allocator> -__vector_base<_Tp, _Allocator>::~__vector_base() -{ - if (__begin_ != nullptr) - { - clear(); - __alloc_traits::deallocate(__alloc(), __begin_, capacity()); - } -} +}; template <class _Tp, class _Allocator /* = allocator<_Tp> */> class _LIBCPP_TEMPLATE_VIS vector + // This base class is historical, but it needs to remain for ABI compatibility. : private __vector_base<_Tp, _Allocator> { private: - typedef __vector_base<_Tp, _Allocator> __base; - typedef allocator<_Tp> __default_allocator_type; + typedef __vector_base<_Tp, _Allocator> __base; + typedef allocator<_Tp> __default_allocator_type; public: - typedef vector __self; - typedef _Tp value_type; - typedef _Allocator allocator_type; - typedef typename __base::__alloc_traits __alloc_traits; - typedef typename __base::reference reference; - typedef typename __base::const_reference const_reference; - typedef typename __base::size_type size_type; - typedef typename __base::difference_type difference_type; - typedef typename __base::pointer pointer; - typedef typename __base::const_pointer const_pointer; + typedef vector __self; + typedef _Tp value_type; + typedef _Allocator allocator_type; + typedef allocator_traits<allocator_type> __alloc_traits; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef typename __allocator_traits<allocator_type>::size_type size_type; + typedef typename __alloc_traits::difference_type difference_type; + typedef typename __alloc_traits::pointer pointer; + typedef typename __alloc_traits::const_pointer const_pointer; #if _YNDX_LIBCPP_MAKE_VECTOR_ITERATOR_POINTERS == 1 - typedef typename __base::pointer iterator; - typedef typename __base::const_pointer const_iterator; + typedef pointer iterator; + typedef const_pointer const_iterator; #else - typedef __wrap_iter<pointer> iterator; - typedef __wrap_iter<const_pointer> const_iterator; + typedef __wrap_iter<pointer> iterator; + typedef __wrap_iter<const_pointer> const_iterator; #endif - typedef _VSTD::reverse_iterator<iterator> reverse_iterator; - typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; + typedef _VSTD::reverse_iterator<iterator> reverse_iterator; + typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; static_assert((is_same<typename allocator_type::value_type, value_type>::value), "Allocator::value_type must be same type as value_type"); @@ -562,10 +431,16 @@ public: _LIBCPP_INLINE_VISIBILITY ~vector() { - __annotate_delete(); + __annotate_delete(); #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->__erase_c(this); + __get_db()->__erase_c(this); #endif + + if (this->__begin_ != nullptr) + { + __clear(); + __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); + } } vector(const vector& __x); @@ -670,7 +545,7 @@ public: {return static_cast<size_type>(this->__end_ - this->__begin_);} _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT - {return __base::capacity();} + {return static_cast<size_type>(__end_cap() - this->__begin_);} _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const _NOEXCEPT {return this->__begin_ == this->__end_;} @@ -783,7 +658,7 @@ public: void clear() _NOEXCEPT { size_type __old_size = size(); - __base::clear(); + __clear(); __annotate_shrink(__old_size); __invalidate_all_iterators(); } @@ -849,7 +724,7 @@ private: { __invalidate_iterators_past(__new_last); size_type __old_size = size(); - __base::__destruct_at_end(__new_last); + __base_destruct_at_end(__new_last); __annotate_shrink(__old_size); } @@ -921,7 +796,7 @@ private: struct _ConstructTransaction { explicit _ConstructTransaction(vector &__v, size_type __n) - : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { + : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { #ifndef _LIBCPP_HAS_NO_ASAN __v_.__annotate_increase(__n); #endif @@ -952,11 +827,95 @@ private: _VSTD::forward<_Args>(__args)...); ++__tx.__pos_; } + + _LIBCPP_INLINE_VISIBILITY + allocator_type& __alloc() _NOEXCEPT + {return this->__end_cap_.second();} + _LIBCPP_INLINE_VISIBILITY + const allocator_type& __alloc() const _NOEXCEPT + {return this->__end_cap_.second();} + _LIBCPP_INLINE_VISIBILITY + pointer& __end_cap() _NOEXCEPT + {return this->__end_cap_.first();} + _LIBCPP_INLINE_VISIBILITY + const pointer& __end_cap() const _NOEXCEPT + {return this->__end_cap_.first();} + + _LIBCPP_INLINE_VISIBILITY + void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);} + + _LIBCPP_INLINE_VISIBILITY + void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { + pointer __soon_to_be_end = this->__end_; + while (__new_last != __soon_to_be_end) + __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); + this->__end_ = __new_last; + } + + _LIBCPP_INLINE_VISIBILITY + void __copy_assign_alloc(const vector& __c) + {__copy_assign_alloc(__c, integral_constant<bool, + __alloc_traits::propagate_on_container_copy_assignment::value>());} + + _LIBCPP_INLINE_VISIBILITY + void __move_assign_alloc(vector& __c) + _NOEXCEPT_( + !__alloc_traits::propagate_on_container_move_assignment::value || + is_nothrow_move_assignable<allocator_type>::value) + {__move_assign_alloc(__c, integral_constant<bool, + __alloc_traits::propagate_on_container_move_assignment::value>());} + + _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI + void __throw_length_error() const { +#ifndef _LIBCPP_NO_EXCEPTIONS + __vector_base_common<true>::__throw_length_error(); +#else + _VSTD::abort(); +#endif + } + + _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI + void __throw_out_of_range() const { +#ifndef _LIBCPP_NO_EXCEPTIONS + __vector_base_common<true>::__throw_out_of_range(); +#else + _VSTD::abort(); +#endif + } + + _LIBCPP_INLINE_VISIBILITY + void __copy_assign_alloc(const vector& __c, true_type) + { + if (__alloc() != __c.__alloc()) + { + __clear(); + __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); + this->__begin_ = this->__end_ = __end_cap() = nullptr; + } + __alloc() = __c.__alloc(); + } + + _LIBCPP_INLINE_VISIBILITY + void __copy_assign_alloc(const vector&, false_type) + {} + + _LIBCPP_INLINE_VISIBILITY + void __move_assign_alloc(vector& __c, true_type) + _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) + { + __alloc() = _VSTD::move(__c.__alloc()); + } + + _LIBCPP_INLINE_VISIBILITY + void __move_assign_alloc(vector&, false_type) + _NOEXCEPT + {} }; #if _LIBCPP_STD_VER >= 17 template<class _InputIterator, class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > vector(_InputIterator, _InputIterator) @@ -964,6 +923,7 @@ vector(_InputIterator, _InputIterator) template<class _InputIterator, class _Alloc, + class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, class = enable_if_t<__is_allocator<_Alloc>::value> > vector(_InputIterator, _InputIterator, _Alloc) @@ -1331,7 +1291,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->__insert_c(this); - __get_db()->swap(this, &__x); + __get_db()->swap(this, _VSTD::addressof(__x)); #endif this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; @@ -1354,7 +1314,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type> this->__end_cap() = __x.__end_cap(); __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->swap(this, &__x); + __get_db()->swap(this, _VSTD::addressof(__x)); #endif } else @@ -1409,7 +1369,7 @@ void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) _NOEXCEPT_(__alloc_traits::is_always_equal::value) { - if (__base::__alloc() != __c.__alloc()) + if (__alloc() != __c.__alloc()) { typedef move_iterator<iterator> _Ip; assign(_Ip(__c.begin()), _Ip(__c.end())); @@ -1424,13 +1384,13 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { __vdeallocate(); - __base::__move_assign_alloc(__c); // this can throw + __move_assign_alloc(__c); // this can throw this->__begin_ = __c.__begin_; this->__end_ = __c.__end_; this->__end_cap() = __c.__end_cap(); __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->swap(this, &__c); + __get_db()->swap(this, _VSTD::addressof(__c)); #endif } @@ -1443,7 +1403,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x) { if (this != _VSTD::addressof(__x)) { - __base::__copy_assign_alloc(__x); + __copy_assign_alloc(__x); assign(__x.__begin_, __x.__end_); } return *this; @@ -1625,6 +1585,8 @@ vector<_Tp, _Allocator>::reserve(size_type __n) { if (__n > capacity()) { + if (__n > max_size()) + this->__throw_length_error(); allocator_type& __a = this->__alloc(); __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); __swap_out_circular_buffer(__v); @@ -1749,7 +1711,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::erase(iterator) called with an iterator not" " referring to this vector"); #endif @@ -1768,11 +1730,11 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, - "vector::erase(iterator, iterator) called with an iterator not" + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this, + "vector::erase(iterator, iterator) called with an iterator not" " referring to this vector"); - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, - "vector::erase(iterator, iterator) called with an iterator not" + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this, + "vector::erase(iterator, iterator) called with an iterator not" " referring to this vector"); #endif _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); @@ -1809,7 +1771,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, x) called with an iterator not" " referring to this vector"); #endif @@ -1846,7 +1808,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, x) called with an iterator not" " referring to this vector"); #endif @@ -1879,7 +1841,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::emplace(iterator, x) called with an iterator not" " referring to this vector"); #endif @@ -1914,7 +1876,7 @@ typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, n, x) called with an iterator not" " referring to this vector"); #endif @@ -1965,7 +1927,7 @@ typename enable_if vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, range) called with an iterator not" " referring to this vector"); #endif @@ -2018,7 +1980,7 @@ typename enable_if vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { #if _LIBCPP_DEBUG_LEVEL == 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, "vector::insert(iterator, range) called with an iterator not" " referring to this vector"); #endif @@ -2116,7 +2078,7 @@ vector<_Tp, _Allocator>::swap(vector& __x) _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); #if _LIBCPP_DEBUG_LEVEL == 2 - __get_db()->swap(this, &__x); + __get_db()->swap(this, _VSTD::addressof(__x)); #endif } @@ -3016,7 +2978,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) __size_ = __n; else { - vector __v(__alloc()); + vector __v(get_allocator()); __v.reserve(__recommend(__n)); __v.__size_ = __n; swap(__v); @@ -3071,7 +3033,9 @@ vector<bool, _Allocator>::reserve(size_type __n) { if (__n > capacity()) { - vector __v(this->__alloc()); + if (__n > max_size()) + this->__throw_length_error(); + vector __v(this->get_allocator()); __v.__vallocate(__n); __v.__construct_at_end(this->begin(), this->end()); swap(__v); @@ -3141,7 +3105,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __ } else { - vector __v(__alloc()); + vector __v(get_allocator()); __v.reserve(__recommend(__size_ + 1)); __v.__size_ = __size_ + 1; __r = _VSTD::copy(cbegin(), __position, __v.begin()); @@ -3167,7 +3131,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const } else { - vector __v(__alloc()); + vector __v(get_allocator()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), __position, __v.begin()); @@ -3196,7 +3160,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir ++this->__size_; back() = *__first; } - vector __v(__alloc()); + vector __v(get_allocator()); if (__first != __last) { #ifndef _LIBCPP_NO_EXCEPTIONS @@ -3246,7 +3210,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f } else { - vector __v(__alloc()); + vector __v(get_allocator()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), __position, __v.begin()); @@ -3313,7 +3277,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x) } else { - vector __v(__alloc()); + vector __v(get_allocator()); __v.reserve(__recommend(__size_ + __n)); __v.__size_ = __size_ + __n; __r = _VSTD::copy(cbegin(), cend(), __v.begin()); diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp index 42b5641b43..ec8a811262 100644 --- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp @@ -4561,6 +4561,18 @@ static bool checked_string_to_wchar_convert(wchar_t& dest, } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +#ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS +static bool is_narrow_non_breaking_space(const char* ptr) { + // https://www.fileformat.info/info/unicode/char/202f/index.htm + return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf'; +} + +static bool is_non_breaking_space(const char* ptr) { + // https://www.fileformat.info/info/unicode/char/0a/index.htm + return ptr[0] == '\xc2' && ptr[1] == '\xa0'; +} +#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS + static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t __loc) { @@ -4593,6 +4605,13 @@ static bool checked_string_to_char_convert(char& dest, return false; } #else // _LIBCPP_HAS_NO_WIDE_CHARACTERS + // FIXME: Work around specific multibyte sequences that we can reasonably + // translate into a different single byte. + if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) { + dest = ' '; + return true; + } + return false; #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_UNREACHABLE(); diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp index f9e8d44842..29b3c1da76 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp @@ -215,27 +215,6 @@ __get_sp_mut(const void* p) #endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) -void -declare_reachable(void*) -{ -} - -void -declare_no_pointers(char*, size_t) -{ -} - -void -undeclare_no_pointers(char*, size_t) -{ -} - -void* -__undeclare_reachable(void* p) -{ - return p; -} - void* align(size_t alignment, size_t size, void*& ptr, size_t& space) { diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp index 9506822da8..f2072b1435 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp @@ -38,9 +38,6 @@ static_assert(alignof(__libcpp_thread_t) == alignof(HANDLE), ""); static_assert(sizeof(__libcpp_tls_key) == sizeof(DWORD), ""); static_assert(alignof(__libcpp_tls_key) == alignof(DWORD), ""); -static_assert(sizeof(__libcpp_semaphore_t) == sizeof(HANDLE), ""); -static_assert(alignof(__libcpp_semaphore_t) == alignof(HANDLE), ""); - // Mutex int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) { @@ -274,37 +271,4 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) return 0; } -// Semaphores -bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init) -{ - *(PHANDLE)__sem = CreateSemaphoreEx(nullptr, __init, _LIBCPP_SEMAPHORE_MAX, - nullptr, 0, SEMAPHORE_ALL_ACCESS); - return *__sem != nullptr; -} - -bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem) -{ - CloseHandle(*(PHANDLE)__sem); - return true; -} - -bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem) -{ - return ReleaseSemaphore(*(PHANDLE)__sem, 1, nullptr); -} - -bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem) -{ - return WaitForSingleObjectEx(*(PHANDLE)__sem, INFINITE, false) == - WAIT_OBJECT_0; -} - -bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, - chrono::nanoseconds const& __ns) -{ - chrono::milliseconds __ms = chrono::ceil<chrono::milliseconds>(__ns); - return WaitForSingleObjectEx(*(PHANDLE)__sem, __ms.count(), false) == - WAIT_OBJECT_0; -} - _LIBCPP_END_NAMESPACE_STD |