[libcxx-commits] [libcxx] [libc++] Accept iterators instead of raw pointers in __uninitialized_allocator_relocate (PR #114552)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 4 08:05:02 PST 2024


================
@@ -611,20 +611,22 @@ struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};
 //                 [__first, __last) doesn't contain any objects
 //
 // The strong exception guarantee is provided if any of the following are true:
-// - is_nothrow_move_constructible<_Tp>
-// - is_copy_constructible<_Tp>
-// - __libcpp_is_trivially_relocatable<_Tp>
-template <class _Alloc, class _Tp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
-__uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _Tp* __result) {
+// - is_nothrow_move_constructible<_ValueType>
+// - is_copy_constructible<_ValueType>
+// - __libcpp_is_trivially_relocatable<_ValueType>
+template <class _Alloc, class _ContiguousIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocator_relocate(
+    _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {
----------------
ldionne wrote:

What's the issue you're seeing? I think the only issue in the current version of the patch is that I use `_AllocatorDestroyRangeReverse<_Alloc, _ValueType*>` below, and that should be `_AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>` instead, right? Do you see any other issue with fancy pointers?

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


More information about the libcxx-commits mailing list