Skip to content

Commit 544f610

Browse files
authored
[libc++] Use __is_pointer_in_range inside vector::insert (#80624)
1 parent 13c14ad commit 544f610

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libcxx/include/vector

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
351351
#include <__type_traits/type_identity.h>
352352
#include <__utility/exception_guard.h>
353353
#include <__utility/forward.h>
354+
#include <__utility/is_pointer_in_range.h>
354355
#include <__utility/move.h>
355356
#include <__utility/pair.h>
356357
#include <__utility/swap.h>
@@ -1580,14 +1581,13 @@ template <class _Tp, class _Allocator>
15801581
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
15811582
vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {
15821583
pointer __p = this->__begin_ + (__position - begin());
1583-
// We can't compare unrelated pointers inside constant expressions
1584-
if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) {
1584+
if (this->__end_ < this->__end_cap()) {
15851585
if (__p == this->__end_) {
15861586
__construct_one_at_end(__x);
15871587
} else {
15881588
__move_range(__p, this->__end_, __p + 1);
15891589
const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1590-
if (__p <= __xr && __xr < this->__end_)
1590+
if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
15911591
++__xr;
15921592
*__p = *__xr;
15931593
}

0 commit comments

Comments
 (0)