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

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 8 03:03:27 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>,
----------------
frederick-vs-ja wrote:

I'll change back to use `is_convertible` only...

However, [allocator.requirements.general] (and perhaps many other places in the library specification) sometimes only says "(implicit) conversion"/"(implicitly) convertible", while C++ types can be so tricky that explicit and implicit conversions can have different semantics, or the explicit conversion can be ill-formed while the implicit one is not. Maybe an LWG issue, requiring conversions between fancy pointers to be sane, is desired.

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


More information about the libcxx-commits mailing list