[libcxx-commits] [libcxx] [libc++] Implement `ranges::shift_right` (PR #177847)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 28 12:49:49 PST 2026
================
@@ -27,65 +33,70 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
-template <class _ForwardIterator>
-inline _LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator
-shift_right(_ForwardIterator __first,
- _ForwardIterator __last,
- typename iterator_traits<_ForwardIterator>::difference_type __n) {
+template <class _AlgPolicy, class _Iter, class _Sent>
+_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter, _Iter>
+__shift_right(_Iter __first, _Sent __last, typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __n) {
+ _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "n must be greater than or equal to 0");
----------------
ldionne wrote:
```suggestion
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "Providing a negative shift amount to shift_right is UB");
```
https://github.com/llvm/llvm-project/pull/177847
More information about the libcxx-commits
mailing list