aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-12-25 17:35:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-19 21:12:22 +0000
commite710425beb3de4adcf4d601da2f224503f876b6d (patch)
treeaca526ac7dde15560ae28f549319b25647f28363 /contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
parent1bc094c4a0e74dba87a5eb98cf138426a19f702d (diff)
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/shift_left.h')
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shift_left.h43
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