Skip to content

Commit 22c9f1c

Browse files
committed
* s/__i/__prev/ in __is_sorted_until()
* remove bogus __libcpp_is_constant_evaluated() check in __set_intersection() * change comment about checking number of steps in debug mode * s/_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT/_LIBCPP_ASSERT_INTERNAL/ for input validation
1 parent 3006f13 commit 22c9f1c

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

libcxx/include/__algorithm/is_sorted_until.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ template <class _Compare, class _ForwardIterator, class _Sent>
2424
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2525
__is_sorted_until(_ForwardIterator __first, _Sent __last, _Compare&& __comp) {
2626
if (__first != __last) {
27-
_ForwardIterator __i = __first;
27+
_ForwardIterator __prev = __first;
2828
while (++__first != __last) {
29-
if (__comp(*__first, *__i))
29+
if (__comp(*__first, *__prev))
3030
return __first;
31-
__i = __first;
31+
__prev = __first;
3232
}
3333
}
3434
return __first;

libcxx/include/__algorithm/set_intersection.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ __set_intersection(
9999
std::forward_iterator_tag,
100100
std::forward_iterator_tag) {
101101
#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
102-
if (!__libcpp_is_constant_evaluated()) {
103-
_LIBCPP_ASSERT_INTERNAL(
104-
std::__is_sorted_until(__first1, __last1, __comp) == __last1, "set_intersection: input range 1 must be sorted");
105-
_LIBCPP_ASSERT_INTERNAL(
106-
std::__is_sorted_until(__first2, __last2, __comp) == __last2, "set_intersection: input range 2 must be sorted");
107-
}
102+
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
103+
std::__is_sorted_until(__first1, __last1, __comp) == __last1, "set_intersection: input range 1 must be sorted");
104+
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
105+
std::__is_sorted_until(__first2, __last2, __comp) == __last2, "set_intersection: input range 2 must be sorted");
108106
#endif
109107
_LIBCPP_CONSTEXPR std::__identity __proj;
110108
bool __prev_may_be_equal = false;

libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.intersection/set_intersection_complexity.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#include "test_iterators.h"
4545

46-
// Debug mode provides no complexity guarantees, testing them would be a waste of effort.
46+
// We don't check number of operations in Debug mode because they are not stable enough due to additional validations.
4747
#ifdef _LIBCPP_HARDENING_MODE_DEBUG
4848
# define ASSERT_COMPLEXITY(expression) (void)(expression)
4949
#else

0 commit comments

Comments
 (0)