[libcxx-commits] [libcxx] [libc++] Remove allocator support from std::function (PR #140395)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jun 5 10:57:25 PDT 2025


================
@@ -215,20 +145,9 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
     return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...);
   }
 
-  _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {
-    using _Self = __default_alloc_func;
-    unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1)));
-    _Self* __res = ::new ((void*)__hold.get()) _Self(__f_);
-    (void)__hold.release();
-    return __res;
-  }
+  _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const { return new __default_alloc_func(__f_); }
----------------
ldionne wrote:

Here, IIUC the previous code was entirely equivalent to the new code, just more complicated. Can you confirm?

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


More information about the libcxx-commits mailing list