diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h')
-rw-r--r-- | contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h index 35765330bb7f..7d1807b7bbf9 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_iter.h @@ -10,12 +10,12 @@ #define _LIBCPP___ALGORITHM_UNWRAP_ITER_H #include <__config> +#include <__iterator/iterator_traits.h> #include <__memory/pointer_traits.h> -#include <iterator> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header +# pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -43,7 +43,7 @@ struct __unwrap_iter_impl { } }; -#if _LIBCPP_DEBUG_LEVEL < 2 +#ifndef _LIBCPP_ENABLE_DEBUG_MODE template <class _Iter> struct __unwrap_iter_impl<_Iter, true> { @@ -53,7 +53,7 @@ struct __unwrap_iter_impl<_Iter, true> { } }; -#endif // _LIBCPP_DEBUG_LEVEL < 2 +#endif // !_LIBCPP_ENABLE_DEBUG_MODE template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> > inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR @@ -63,20 +63,34 @@ __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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _OrigIter __rewrap_iter(_OrigIter, _OrigIter __result) { return __result; } -template<class _OrigIter, class _UnwrappedIter> -_LIBCPP_HIDE_FROM_ABI +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 |