diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/shift_left.h')
| -rw-r--r-- | contrib/llvm-project/libcxx/include/__algorithm/shift_left.h | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h index c9f2cbb9f7b6..645c58c29119 100644 --- a/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h +++ b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h @@ -22,30 +22,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 template <class _ForwardIterator> -inline _LIBCPP_HIDE_FROM_ABI constexpr -_ForwardIterator -shift_left(_ForwardIterator __first, _ForwardIterator __last, - typename iterator_traits<_ForwardIterator>::difference_type __n) -{ - if (__n == 0) { - return __last; +inline _LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator +shift_left(_ForwardIterator __first, + _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) { + if (__n == 0) { + return __last; + } + + _ForwardIterator __m = __first; + if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) { + if (__n >= __last - __first) { + return __first; } - - _ForwardIterator __m = __first; - if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) { - if (__n >= __last - __first) { - return __first; - } - __m += __n; - } else { - for (; __n > 0; --__n) { - if (__m == __last) { - return __first; - } - ++__m; - } + __m += __n; + } else { + for (; __n > 0; --__n) { + if (__m == __last) { + return __first; + } + ++__m; } - return std::move(__m, __last, __first); + } + return std::move(__m, __last, __first); } #endif // _LIBCPP_STD_VER >= 20 |
