[libcxx-commits] [libcxx] [libc++] Assert that the position passed to insert and emplace is in [begin(), end()] (PR #230490)

Ilyas Mallah via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 13 03:22:17 PDT 2026


================
@@ -1243,6 +1243,10 @@ private:
   template <class _BiIter>
   _LIBCPP_HIDE_FROM_ABI iterator __insert_bidirectional(const_iterator __p, _BiIter __f, _BiIter __l, size_type __n);
 
+  _LIBCPP_HIDE_FROM_ABI bool __is_valid_insert_position(const_iterator __p) const {
+    return begin() <= __p && __p <= end();
----------------
ilyas-mallah wrote:

Done in c5af97ea9d. I didn't see the old `<=` misfire, and the change only stops relying on how iterators from different deques compare. The same check would let `deque::erase` verify the iterator belongs to the deque, which #90919 leaves out, and I can do that in a separate PR if it's useful.

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


More information about the libcxx-commits mailing list