Skip to content

Commit d0ed3b8

Browse files
merge hardening checks
1 parent d1deb23 commit d0ed3b8

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

libcxx/include/__ranges/concat_view.h

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ class concat_view<_Views...>::__iterator {
401401
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
402402
requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...)
403403
{
404-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
405-
!__x.__it_.valueless_by_exception(), "Trying to compare a valueless iterator of concat_view.");
406-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
407-
!__y.__it_.valueless_by_exception(), "Trying to compare a valueless iterator of concat_view.");
404+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
405+
"Trying to compare a valueless iterator of concat_view.");
408406
return __x.__it_ == __y.__it_;
409407
}
410408

@@ -506,10 +504,8 @@ class concat_view<_Views...>::__iterator {
506504
requires((random_access_range<__maybe_const<_Const, _Views>> && ...) &&
507505
(three_way_comparable<__maybe_const<_Const, _Views>> && ...))
508506
{
509-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
510-
!__x.__it_.valueless_by_exception(), "Trying to compare a valueless iterator of concat_view.");
511-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
512-
!__y.__it_.valueless_by_exception(), "Trying to compare a valueless iterator of concat_view.");
507+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
508+
"Trying to compare a valueless iterator of concat_view.");
513509
return __x.__it_ <=> __y.__it_;
514510
}
515511

@@ -542,9 +538,8 @@ class concat_view<_Views...>::__iterator {
542538
(... && indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>>)
543539
{
544540
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
545-
!__x.__it_.valueless_by_exception(), "Trying to swap iterators of concat_view where at least one iterator is valueless.");
546-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
547-
!__y.__it_.valueless_by_exception(), "Trying to swap iterators of concat_view where at least one iterator is valueless.");
541+
!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
542+
"Trying to swap iterators of concat_view where at least one iterator is valueless.");
548543
__variant_detail::__visitation::__variant::__visit_value(
549544
[&](const auto& __it1, const auto& __it2) {
550545
if constexpr (is_same_v<decltype(__it1), decltype(__it2)>) {
@@ -561,9 +556,8 @@ class concat_view<_Views...>::__iterator {
561556
requires __concat_is_random_access<_Const, _Views...>
562557
{
563558
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
564-
!__x.__it_.valueless_by_exception(), "Trying to subtract two iterators of concat_view where at least one iterator is valueless.");
565-
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
566-
!__y.__it_.valueless_by_exception(), "Trying to subtract two iterators of concat_view where at least one iterator is valueless.");
559+
!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
560+
"Trying to subtract two iterators of concat_view where at least one iterator is valueless.");
567561
size_t __ix = __x.__it_.index();
568562
size_t __iy = __y.__it_.index();
569563

libcxx/test/libcxx/ranges/range.adaptors/range.concat/iterator.valueless_by_exception.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ int main() {
104104
TEST_LIBCPP_ASSERT_FAILURE([&] { (void)(it1 += 1); }(), "valueless by exception");
105105
}
106106
}
107-
}
107+
}

0 commit comments

Comments
 (0)