[libcxx-commits] [libcxx] [libc++][hardening] Constrain construction for `__{bounded, wrap}_iter` (PR #115271)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 7 19:53:18 PST 2024


================
@@ -67,7 +72,13 @@ struct __bounded_iter {
   _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;
   _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&)      = default;
 
-  template <class _OtherIterator, __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value, int> = 0>
+  template < class _OtherIterator,
+             __enable_if_t<
+                 _And<is_constructible<_Iterator, const _OtherIterator&>,
+                      is_convertible<const _OtherIterator&, _Iterator>,
+                      _Or<is_same<reference, __iter_reference<_OtherIterator> >,
+                          is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value,
----------------
frederick-vs-ja wrote:

Yes. [[iterator.concept.contiguous]](https://eel.is/c++draft/iterator.concept.contiguous) and [[allocator.requirements.general]/92](https://eel.is/c++draft/allocator.requirements.general#92) (for possibly fancy pointers, note that `std::addressof` rejects rvalues) require this.

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


More information about the libcxx-commits mailing list