diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2023-11-02 19:27:12 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2023-11-02 20:14:23 +0300 |
commit | ea7266e3afdfe76274c756747fbd24626e1c205a (patch) | |
tree | 9b8370f3cf8d4399fc960a2c50aa9759f5acf554 /contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h | |
parent | a528d5d25d42706fe385120b27e1df3a257823fb (diff) | |
download | ydb-ea7266e3afdfe76274c756747fbd24626e1c205a.tar.gz |
Upd libc++ to 14 Jun 2022 1cf4113952ae3e4cc75decdf6feb3ce5dd8ca4a1
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h index 00587ecb5b..2a4e535c6f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h @@ -56,25 +56,36 @@ pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, return std::make_pair(__first + __n, __result + __n); } -template <class _InValueT, - class _OutValueT, - class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value - && is_trivially_copy_assignable<_OutValueT>::value> > +template <class _InIter, class _OutIter, + __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value + && __is_cpp17_contiguous_iterator<_InIter>::value + && __is_cpp17_contiguous_iterator<_OutIter>::value + && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -pair<reverse_iterator<_InValueT*>, reverse_iterator<_OutValueT*> > -__copy_impl(reverse_iterator<_InValueT*> __first, - reverse_iterator<_InValueT*> __last, - reverse_iterator<_OutValueT*> __result) { - auto __first_base = __first.base(); - auto __last_base = __last.base(); - auto __result_base = __result.base(); +pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> > +__copy_impl(reverse_iterator<_InIter> __first, + reverse_iterator<_InIter> __last, + reverse_iterator<_OutIter> __result) { + auto __first_base = std::__unwrap_iter(__first.base()); + auto __last_base = std::__unwrap_iter(__last.base()); + auto __result_base = std::__unwrap_iter(__result.base()); auto __result_first = __result_base - (__first_base - __last_base); std::__copy_impl(__last_base, __first_base, __result_first); - return std::make_pair(__last, reverse_iterator<_OutValueT*>(__result_first)); + return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); } template <class _InIter, class _Sent, class _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<reverse_iterator<reverse_iterator<_InIter> >, reverse_iterator<reverse_iterator<_OutIter> > > +__copy_impl(reverse_iterator<reverse_iterator<_InIter> > __first, + reverse_iterator<reverse_iterator<_Sent> > __last, + reverse_iterator<reverse_iterator<_OutIter> > __result); + +template <class _InIter, class _Sent, class _OutIter, + __enable_if_t<!(is_copy_constructible<_InIter>::value + && is_copy_constructible<_Sent>::value + && is_copy_constructible<_OutIter>::value), int> = 0 > +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) { return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result)); } @@ -82,13 +93,26 @@ pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) template <class _InIter, class _Sent, class _OutIter, __enable_if_t<is_copy_constructible<_InIter>::value && is_copy_constructible<_Sent>::value - && is_copy_constructible<_OutIter>::value> > + && is_copy_constructible<_OutIter>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) { +pair<_InIter, _OutIter> +__copy(_InIter __first, _Sent __last, _OutIter __result) { auto __ret = std::__copy_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result)); return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); } +// __unwrap_iter can't unwrap random_access_iterators, so we need to unwrap two reverse_iterators manually +template <class _InIter, class _Sent, class _OutIter> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<reverse_iterator<reverse_iterator<_InIter> >, reverse_iterator<reverse_iterator<_OutIter> > > +__copy_impl(reverse_iterator<reverse_iterator<_InIter> > __first, + reverse_iterator<reverse_iterator<_Sent> > __last, + reverse_iterator<reverse_iterator<_OutIter> > __result) { + auto __ret = std::__copy(__first.base().base(), __last.base().base(), __result.base().base()); + return std::make_pair(reverse_iterator<reverse_iterator<_InIter> >(reverse_iterator<_InIter>(__ret.first)), + reverse_iterator<reverse_iterator<_OutIter> >(reverse_iterator<_OutIter>(__ret.second))); +} + template <class _InputIterator, class _OutputIterator> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator |