diff options
Diffstat (limited to 'include/memory')
-rw-r--r-- | include/memory | 466 |
1 files changed, 241 insertions, 225 deletions
diff --git a/include/memory b/include/memory index 7a3281e17931c..b4c2b35c0b73a 100644 --- a/include/memory +++ b/include/memory @@ -164,6 +164,7 @@ template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept template <class T> void return_temporary_buffer(T* p) noexcept; template <class T> T* addressof(T& r) noexcept; +template <class T> T* addressof(const T&& r) noexcept = delete; template <class InputIterator, class ForwardIterator> ForwardIterator @@ -180,6 +181,33 @@ template <class ForwardIterator, class Size, class T> ForwardIterator uninitialized_fill_n(ForwardIterator first, Size n, const T& x); +template <class T> +void destroy_at(T* location); + +template <class ForwardIterator> + void destroy(ForwardIterator first, ForwardIterator last); + +template <class ForwardIterator, class Size> + ForwardIterator destroy_n(ForwardIterator first, Size n); + +template <class InputIterator, class ForwardIterator> + ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result); + +template <class InputIterator, class Size, class ForwardIterator> + pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result); + +template <class ForwardIterator> + void uninitialized_value_construct(ForwardIterator first, ForwardIterator last); + +template <class ForwardIterator, class Size> + ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n); + +template <class ForwardIterator> + void uninitialized_default_construct(ForwardIterator first, ForwardIterator last); + +template <class ForwardIterator, class Size> + ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); + template <class Y> struct auto_ptr_ref {}; template<class X> @@ -610,9 +638,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include <tuple> #include <stdexcept> #include <cstring> -#if defined(_LIBCPP_NO_EXCEPTIONS) - #include <cassert> -#endif #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include <atomic> @@ -639,7 +664,19 @@ _ValueType __libcpp_relaxed_load(_ValueType const* __value) { #endif } -// addressof moved to <__functional_base> +template <class _ValueType> +inline _LIBCPP_ALWAYS_INLINE +_ValueType __libcpp_acquire_load(_ValueType const* __value) { +#if !defined(_LIBCPP_HAS_NO_THREADS) && \ + defined(__ATOMIC_ACQUIRE) && \ + (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407) + return __atomic_load_n(__value, __ATOMIC_ACQUIRE); +#else + return *__value; +#endif +} + +// addressof moved to <type_traits> template <class _Tp> class allocator; @@ -792,7 +829,7 @@ public: template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> struct __pointer_traits_rebind { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Tp::template rebind<_Up> type; #else typedef typename _Tp::template rebind<_Up>::other type; @@ -804,7 +841,7 @@ struct __pointer_traits_rebind template <template <class, class...> class _Sp, class _Tp, class ..._Args, class _Up> struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type; #else typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; @@ -822,7 +859,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> template <template <class> class _Sp, class _Tp, class _Up> struct __pointer_traits_rebind<_Sp<_Tp>, _Up, true> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Sp<_Tp>::template rebind<_Up> type; #else typedef typename _Sp<_Tp>::template rebind<_Up>::other type; @@ -838,7 +875,7 @@ struct __pointer_traits_rebind<_Sp<_Tp>, _Up, false> template <template <class, class> class _Sp, class _Tp, class _A0, class _Up> struct __pointer_traits_rebind<_Sp<_Tp, _A0>, _Up, true> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Sp<_Tp, _A0>::template rebind<_Up> type; #else typedef typename _Sp<_Tp, _A0>::template rebind<_Up>::other type; @@ -855,7 +892,7 @@ template <template <class, class, class> class _Sp, class _Tp, class _A0, class _A1, class _Up> struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1>, _Up, true> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up> type; #else typedef typename _Sp<_Tp, _A0, _A1>::template rebind<_Up>::other type; @@ -873,7 +910,7 @@ template <template <class, class, class, class> class _Sp, class _Tp, class _A0, class _A1, class _A2, class _Up> struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, true> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up> type; #else typedef typename _Sp<_Tp, _A0, _A1, _A2>::template rebind<_Up>::other type; @@ -896,12 +933,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pointer_traits typedef typename __pointer_traits_element_type<pointer>::type element_type; typedef typename __pointer_traits_difference_type<pointer>::type difference_type; -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; #else template <class _Up> struct rebind {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;}; -#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#endif // _LIBCPP_CXX03_LANG private: struct __nat {}; @@ -919,7 +956,7 @@ struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> typedef _Tp element_type; typedef ptrdiff_t difference_type; -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG template <class _Up> using rebind = _Up*; #else template <class _Up> struct rebind {typedef _Up* other;}; @@ -936,7 +973,7 @@ public: template <class _From, class _To> struct __rebind_pointer { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename pointer_traits<_From>::template rebind<_To> type; #else typedef typename pointer_traits<_From>::template rebind<_To>::other type; @@ -1000,7 +1037,7 @@ struct __const_pointer template <class _Tp, class _Ptr, class _Alloc> struct __const_pointer<_Tp, _Ptr, _Alloc, false> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type; #else typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type; @@ -1027,7 +1064,7 @@ struct __void_pointer template <class _Ptr, class _Alloc> struct __void_pointer<_Ptr, _Alloc, false> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename pointer_traits<_Ptr>::template rebind<void> type; #else typedef typename pointer_traits<_Ptr>::template rebind<void>::other type; @@ -1054,7 +1091,7 @@ struct __const_void_pointer template <class _Ptr, class _Alloc> struct __const_void_pointer<_Ptr, _Alloc, false> { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename pointer_traits<_Ptr>::template rebind<const void> type; #else typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type; @@ -1285,7 +1322,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _A0, _A1, _A2>, _Up, false> #endif // _LIBCPP_HAS_NO_VARIADICS -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#ifndef _LIBCPP_CXX03_LANG template <class _Alloc, class _SizeType, class _ConstVoidPtr> auto @@ -1308,7 +1345,7 @@ struct __has_allocate_hint { }; -#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#else // _LIBCPP_CXX03_LANG template <class _Alloc, class _SizeType, class _ConstVoidPtr> struct __has_allocate_hint @@ -1316,9 +1353,9 @@ struct __has_allocate_hint { }; -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#endif // _LIBCPP_CXX03_LANG -#if !defined(_LIBCPP_HAS_NO_ADVANCED_SFINAE) && !defined(_LIBCPP_HAS_NO_VARIADICS) +#if !defined(_LIBCPP_CXX03_LANG) template <class _Alloc, class _Tp, class ..._Args> decltype(_VSTD::declval<_Alloc>().construct(_VSTD::declval<_Tp*>(), @@ -1399,7 +1436,7 @@ struct __has_select_on_container_copy_construction { }; -#else // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#else // _LIBCPP_CXX03_LANG #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1437,7 +1474,7 @@ struct __has_select_on_container_copy_construction { }; -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE +#endif // _LIBCPP_CXX03_LANG template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value> struct __alloc_traits_difference_type @@ -1474,16 +1511,16 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits typedef typename __is_always_equal<allocator_type>::type is_always_equal; -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG template <class _Tp> using rebind_alloc = typename __allocator_traits_rebind<allocator_type, _Tp>::type; template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>; -#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#else // _LIBCPP_CXX03_LANG template <class _Tp> struct rebind_alloc {typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;}; template <class _Tp> struct rebind_traits {typedef allocator_traits<typename rebind_alloc<_Tp>::other> other;}; -#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY static pointer allocate(allocator_type& __a, size_type __n) @@ -1568,7 +1605,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits is_trivially_move_constructible<_Tp>::value, void >::type - __construct_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) + __construct_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) @@ -1598,7 +1635,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits is_trivially_move_constructible<_Tp>::value, void >::type - __construct_range_forward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) + __construct_range_forward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { typedef typename remove_const<_Tp>::type _Vp; ptrdiff_t _Np = __end1 - __begin1; @@ -1632,7 +1669,7 @@ struct _LIBCPP_TYPE_VIS_ONLY allocator_traits is_trivially_move_constructible<_Tp>::value, void >::type - __construct_backward(allocator_type& __a, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) + __construct_backward(allocator_type&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) { ptrdiff_t _Np = __end1 - __begin1; __end2 -= _Np; @@ -1695,7 +1732,7 @@ private: template <class _Traits, class _Tp> struct __rebind_alloc_helper { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#ifndef _LIBCPP_CXX03_LANG typedef typename _Traits::template rebind_alloc<_Tp> type; #else typedef typename _Traits::template rebind_alloc<_Tp>::other type; @@ -1730,8 +1767,8 @@ public: _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) { if (__n > max_size()) - __libcpp_throw(length_error("allocator<T>::allocate(size_t n)" - " 'n' exceeds maximum supported size")); + __throw_length_error("allocator<T>::allocate(size_t n)" + " 'n' exceeds maximum supported size"); return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp))); } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT @@ -1826,8 +1863,8 @@ public: _LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0) { if (__n > max_size()) - __libcpp_throw(length_error("allocator<const T>::allocate(size_t n)" - " 'n' exceeds maximum supported size")); + __throw_length_error("allocator<const T>::allocate(size_t n)" + " 'n' exceeds maximum supported size"); return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp))); } _LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT @@ -2068,49 +2105,11 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : __first_(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} -#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && - is_nothrow_copy_constructible<_T2>::value) - : __first_(__p.first()), - __second_(__p.second()) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && - is_nothrow_copy_assignable<_T2>::value) - { - __first_ = __p.first(); - __second_ = __p.second(); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && - is_nothrow_move_constructible<_T2>::value) - : __first_(_VSTD::forward<_T1>(__p.first())), - __second_(_VSTD::forward<_T2>(__p.second())) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && - is_nothrow_move_assignable<_T2>::value) - { - __first_ = _VSTD::forward<_T1>(__p.first()); - __second_ = _VSTD::forward<_T2>(__p.second()); - return *this; - } - -#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + __libcpp_compressed_pair_imp(piecewise_construct_t, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args, __tuple_indices<_I1...>, @@ -2161,47 +2160,11 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : _T1(_VSTD::forward<_T1_param>(__t1)), __second_(_VSTD::forward<_T2_param>(__t2)) {} -#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && - is_nothrow_copy_constructible<_T2>::value) - : _T1(__p.first()), __second_(__p.second()) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && - is_nothrow_copy_assignable<_T2>::value) - { - _T1::operator=(__p.first()); - __second_ = __p.second(); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && - is_nothrow_move_constructible<_T2>::value) - : _T1(_VSTD::move(__p.first())), __second_(_VSTD::forward<_T2>(__p.second())) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && - is_nothrow_move_assignable<_T2>::value) - { - _T1::operator=(_VSTD::move(__p.first())); - __second_ = _VSTD::forward<_T2>(__p.second()); - return *this; - } - -#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + __libcpp_compressed_pair_imp(piecewise_construct_t, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args, __tuple_indices<_I1...>, @@ -2253,47 +2216,11 @@ public: is_nothrow_move_constructible<_T2>::value) : _T2(_VSTD::forward<_T2_param>(__t2)), __first_(_VSTD::forward<_T1_param>(__t1)) {} -#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && - is_nothrow_copy_constructible<_T2>::value) - : _T2(__p.second()), __first_(__p.first()) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && - is_nothrow_copy_assignable<_T2>::value) - { - _T2::operator=(__p.second()); - __first_ = __p.first(); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && - is_nothrow_move_constructible<_T2>::value) - : _T2(_VSTD::forward<_T2>(__p.second())), __first_(_VSTD::move(__p.first())) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && - is_nothrow_move_assignable<_T2>::value) - { - _T2::operator=(_VSTD::forward<_T2>(__p.second())); - __first_ = _VSTD::move(__p.first()); - return *this; - } - -#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + __libcpp_compressed_pair_imp(piecewise_construct_t, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args, __tuple_indices<_I1...>, @@ -2343,47 +2270,11 @@ public: _LIBCPP_INLINE_VISIBILITY __libcpp_compressed_pair_imp(_T1_param __t1, _T2_param __t2) : _T1(_VSTD::forward<_T1_param>(__t1)), _T2(_VSTD::forward<_T2_param>(__t2)) {} -#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && - is_nothrow_copy_constructible<_T2>::value) - : _T1(__p.first()), _T2(__p.second()) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(const __libcpp_compressed_pair_imp& __p) - _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && - is_nothrow_copy_assignable<_T2>::value) - { - _T1::operator=(__p.first()); - _T2::operator=(__p.second()); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && - is_nothrow_move_constructible<_T2>::value) - : _T1(_VSTD::move(__p.first())), _T2(_VSTD::move(__p.second())) {} - - _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp& operator=(__libcpp_compressed_pair_imp&& __p) - _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && - is_nothrow_move_assignable<_T2>::value) - { - _T1::operator=(_VSTD::move(__p.first())); - _T2::operator=(_VSTD::move(__p.second())); - return *this; - } - -#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2> _LIBCPP_INLINE_VISIBILITY - __libcpp_compressed_pair_imp(piecewise_construct_t __pc, + __libcpp_compressed_pair_imp(piecewise_construct_t, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args, __tuple_indices<_I1...>, @@ -2430,40 +2321,6 @@ public: _LIBCPP_INLINE_VISIBILITY __compressed_pair(_T1_param __t1, _T2_param __t2) : base(_VSTD::forward<_T1_param>(__t1), _VSTD::forward<_T2_param>(__t2)) {} -#if defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(const __compressed_pair& __p) - _NOEXCEPT_(is_nothrow_copy_constructible<_T1>::value && - is_nothrow_copy_constructible<_T2>::value) - : base(__p) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair& operator=(const __compressed_pair& __p) - _NOEXCEPT_(is_nothrow_copy_assignable<_T1>::value && - is_nothrow_copy_assignable<_T2>::value) - { - base::operator=(__p); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(__compressed_pair&& __p) - _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value && - is_nothrow_move_constructible<_T2>::value) - : base(_VSTD::move(__p)) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair& operator=(__compressed_pair&& __p) - _NOEXCEPT_(is_nothrow_move_assignable<_T1>::value && - is_nothrow_move_assignable<_T2>::value) - { - base::operator=(_VSTD::move(__p)); - return *this; - } - -#endif // defined(_LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS) && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - #ifndef _LIBCPP_HAS_NO_VARIADICS template <class... _Args1, class... _Args2> @@ -2526,7 +2383,7 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, false> template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY default_delete { -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; #else _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} @@ -2546,7 +2403,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> { public: -#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; #else _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT {} @@ -3488,6 +3345,17 @@ struct __scalar_hash<_Tp, 4> } }; +_LIBCPP_INLINE_VISIBILITY +inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { + struct _PairT { + size_t first; + size_t second; + }; + typedef __scalar_hash<_PairT> _HashT; + const _PairT __p = {__lhs, __rhs}; + return _HashT()(__p); +} + template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> : public unary_function<_Tp*, size_t> @@ -3671,6 +3539,148 @@ uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) return __f; } +#if _LIBCPP_STD_VER > 14 + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +void destroy_at(_Tp* __loc) { + _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at"); + __loc->~_Tp(); +} + +template <class _ForwardIterator> +inline _LIBCPP_INLINE_VISIBILITY +void destroy(_ForwardIterator __first, _ForwardIterator __last) { + for (; __first != __last; ++__first) + _VSTD::destroy_at(_VSTD::addressof(*__first)); +} + +template <class _ForwardIterator, class _Size> +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { + for (; __n > 0; (void)++__first, --__n) + _VSTD::destroy_at(_VSTD::addressof(*__first)); + return __first; +} + +template <class _ForwardIterator> +inline _LIBCPP_INLINE_VISIBILITY +void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) { + using _Vt = typename iterator_traits<_ForwardIterator>::value_type; + auto __idx = __first; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __idx != __last; ++__idx) + ::new((void*)_VSTD::addressof(*__idx)) _Vt; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first, __idx); + throw; + } +#endif +} + +template <class _ForwardIterator, class _Size> +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { + using _Vt = typename iterator_traits<_ForwardIterator>::value_type; + auto __idx = __first; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __n > 0; (void)++__idx, --__n) + ::new((void*)_VSTD::addressof(*__idx)) _Vt; + return __idx; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first, __idx); + throw; + } +#endif +} + + +template <class _ForwardIterator> +inline _LIBCPP_INLINE_VISIBILITY +void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) { + using _Vt = typename iterator_traits<_ForwardIterator>::value_type; + auto __idx = __first; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __idx != __last; ++__idx) + ::new((void*)_VSTD::addressof(*__idx)) _Vt(); +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first, __idx); + throw; + } +#endif +} + +template <class _ForwardIterator, class _Size> +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { + using _Vt = typename iterator_traits<_ForwardIterator>::value_type; + auto __idx = __first; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __n > 0; (void)++__idx, --__n) + ::new((void*)_VSTD::addressof(*__idx)) _Vt(); + return __idx; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first, __idx); + throw; + } +#endif +} + + +template <class _InputIt, class _ForwardIt> +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __first_res) { + using _Vt = typename iterator_traits<_ForwardIt>::value_type; + auto __idx = __first_res; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __first != __last; (void)++__idx, ++__first) + ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first)); + return __idx; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first_res, __idx); + throw; + } +#endif +} + +template <class _InputIt, class _Size, class _ForwardIt> +inline _LIBCPP_INLINE_VISIBILITY +pair<_InputIt, _ForwardIt> +uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) { + using _Vt = typename iterator_traits<_ForwardIt>::value_type; + auto __idx = __first_res; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { +#endif + for (; __n > 0; ++__idx, (void)++__first, --__n) + ::new((void*)_VSTD::addressof(*__idx)) _Vt(std::move(*__first)); + return {__first, __idx}; +#ifndef _LIBCPP_NO_EXCEPTIONS + } catch (...) { + _VSTD::destroy(__first_res, __idx); + throw; + } +#endif +} + + +#endif // _LIBCPP_STD_VER > 14 + class _LIBCPP_EXCEPTION_ABI bad_weak_ptr : public std::exception { @@ -3679,6 +3689,16 @@ public: virtual const char* what() const _NOEXCEPT; }; +_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE +void __throw_bad_weak_ptr() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_weak_ptr(); +#else + _VSTD::abort(); +#endif +} + template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr; class _LIBCPP_TYPE_VIS __shared_count @@ -5335,11 +5355,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) { if (__cntrl_ == 0) -#ifndef _LIBCPP_NO_EXCEPTIONS - throw bad_weak_ptr(); -#else - assert(!"bad_weak_ptr"); -#endif + __throw_bad_weak_ptr(); } template<class _Tp> |