aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/include/__algorithm')
-rw-r--r--libcxx/include/__algorithm/copy.h19
-rw-r--r--libcxx/include/__algorithm/unwrap_iter.h22
2 files changed, 18 insertions, 23 deletions
diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h
index 2a4e535..886a1ac 100644
--- a/libcxx/include/__algorithm/copy.h
+++ b/libcxx/include/__algorithm/copy.h
@@ -74,13 +74,6 @@ __copy_impl(reverse_iterator<_InIter> __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
@@ -101,18 +94,6 @@ __copy(_InIter __first, _Sent __last, _OutIter __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
diff --git a/libcxx/include/__algorithm/unwrap_iter.h b/libcxx/include/__algorithm/unwrap_iter.h
index be33194..7d1807b 100644
--- a/libcxx/include/__algorithm/unwrap_iter.h
+++ b/libcxx/include/__algorithm/unwrap_iter.h
@@ -63,6 +63,22 @@ __unwrap_iter(_Iter __i) _NOEXCEPT
return _Impl::__apply(__i);
}
+template <class _OrigIter, class _UnwrappedIter>
+struct __rewrap_iter_impl {
+ static _LIBCPP_CONSTEXPR _OrigIter __apply(_OrigIter __first, _UnwrappedIter __result) {
+ // Precondition: __result is reachable from __first
+ // Precondition: _OrigIter is a contiguous iterator
+ return __first + (__result - std::__unwrap_iter(__first));
+ }
+};
+
+template <class _OrigIter>
+struct __rewrap_iter_impl<_OrigIter, _OrigIter> {
+ static _LIBCPP_CONSTEXPR _OrigIter __apply(_OrigIter, _OrigIter __result) {
+ return __result;
+ }
+};
+
template<class _OrigIter>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
@@ -70,13 +86,11 @@ _OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
return __result;
}
-template<class _OrigIter, class _UnwrappedIter>
+template<class _OrigIter, class _UnwrappedIter, class _Impl = __rewrap_iter_impl<_OrigIter, _UnwrappedIter> >
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
{
- // Precondition: __result is reachable from __first
- // Precondition: _OrigIter is a contiguous iterator
- return __first + (__result - _VSTD::__unwrap_iter(__first));
+ return _Impl::__apply(__first, __result);
}
_LIBCPP_END_NAMESPACE_STD