[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
================
@@ -257,84 +176,38 @@ class __base<_Rp(_ArgTypes...)> {
// __func implements __base for a given functor type.
-template <class _FD, class _Alloc, class _FB>
+template <class _FD, class _FB>
class __func;
-template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
-class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
- __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_;
+template <class _Fp, class _Rp, class... _ArgTypes>
+class __func<_Fp, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
+ _Fp __func_;
----------------
ldionne wrote:
I reckon this is not an ABI break because `std::function` is type erased. Hence, anyone with a `std::function<R(Args..)>` on their ABI boundary will access the underlying callable object via its vtable, which does the right thing. So if an existing executable is producing an old-style `__func<_Fp, _Alloc, _Rp(_ArgTypes...)>` object, it'll still work with the current implementation of `std::function`, even though the same source code would now instead lead to a new-style `__func<_Fp, _Rp(_ArgTypes...)>` object being created if recompiled.
https://github.com/llvm/llvm-project/pull/140395
More information about the libcxx-commits
mailing list