[libcxx-commits] [libcxx] [libc++] Add input validation for set_intersection() in debug mode. (PR #101508)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 30 07:39:03 PDT 2024


================
@@ -20,18 +20,18 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-template <class _Compare, class _ForwardIterator>
+template <class _Compare, class _ForwardIterator, class _Sent>
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
-__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
+__is_sorted_until(_ForwardIterator __first, _Sent __last, _Compare&& __comp) {
   if (__first != __last) {
     _ForwardIterator __i = __first;
----------------
ldionne wrote:

```suggestion
    _ForwardIterator __prev = __first;
```

This makes the code quite a bit clearer.

https://github.com/llvm/llvm-project/pull/101508


More information about the libcxx-commits mailing list