[libcxx-commits] [libcxx] [libc++] Simplify std::function implementation further (PR #145153)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 16 02:08:50 PDT 2025
================
@@ -206,12 +204,13 @@ class __value_func<_Rp(_ArgTypes...)> {
_LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) {
typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun;
- if (__function::__not_null(__f)) {
- if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) {
- __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f));
- } else {
- __f_ = new _Fun(std::move(__f));
- }
+ if (__function::__is_null(__f))
+ return;
+
+ if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) {
+ __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f));
----------------
philnik777 wrote:
`_Fun` is always a library-internal type, so I don't think users are allowed to hijack it.
https://github.com/llvm/llvm-project/pull/145153
More information about the libcxx-commits
mailing list