@@ -351,6 +351,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
351
351
#include < __type_traits/type_identity.h>
352
352
#include < __utility/exception_guard.h>
353
353
#include < __utility/forward.h>
354
+ #include < __utility/is_pointer_in_range.h>
354
355
#include < __utility/move.h>
355
356
#include < __utility/pair.h>
356
357
#include < __utility/swap.h>
@@ -1580,14 +1581,13 @@ template <class _Tp, class _Allocator>
1580
1581
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1581
1582
vector<_Tp, _Allocator>::insert (const_iterator __position, const_reference __x) {
1582
1583
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 ()) {
1585
1585
if (__p == this ->__end_ ) {
1586
1586
__construct_one_at_end (__x);
1587
1587
} else {
1588
1588
__move_range (__p, this ->__end_ , __p + 1 );
1589
1589
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)) )
1591
1591
++__xr;
1592
1592
*__p = *__xr;
1593
1593
}
0 commit comments