Skip to content

Commit c2fc0dc

Browse files
committed
[libc++][ranges] check the precondition in '__shift_left'
1 parent 357f4eb commit c2fc0dc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libcxx/include/__algorithm/shift_left.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
template <class _AlgPolicy, class _Iter, class _Sent>
3030
_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter, _Iter>
3131
__shift_left(_Iter __first, _Sent __last, typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __n) {
32+
_LIBCPP_ASSERT_UNCATEGORIZED(__n >= 0, "__n must be greater than or equal to 0");
33+
3234
if (__n == 0) {
3335
_Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
3436
return {std::move(__first), std::move(__end)};

0 commit comments

Comments
 (0)