[libcxx-commits] [libcxx] [libc++] Remove redundant and somewhat confusing assertions around advance() (PR #133276)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 3 15:40:25 PDT 2025
================
@@ -65,8 +65,7 @@ template < class _InputIter,
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) {
typedef typename iterator_traits<_InputIter>::difference_type _Difference;
_Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n));
- // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
- _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
+ _LIBCPP_ASSERT_PEDANTIC(__has_bidirectional_iterator_category<_InputIter>::value || __n >= 0,
"Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
----------------
ldionne wrote:
I'll do this as a follow-up.
https://github.com/llvm/llvm-project/pull/133276
More information about the libcxx-commits
mailing list