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

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 12 20:54:14 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();
----------------
frederick-vs-ja wrote:

I guess we should inspect the iterator's `__m_iter_` member here. I'm a bit afraid that when `__p` points into another `deque`, the relation operators don't always work well.

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


More information about the libcxx-commits mailing list