[PATCH] D55045: Add a version of std::function that includes a few optimizations.

Eric Fiselier via Phabricator reviews at reviews.llvm.org
Thu Nov 29 08:59:35 PST 2018


EricWF added a comment.

Still seeing a bunch of unreserved names. Everything has to use ugly identifiers unless it's specified in the standard.



================
Comment at: include/functional:1646
+  // Returns a __fun for an empty functor.
+  static _Rp call_empty(const __storage*, _ArgTypes...) {
+    __throw_bad_function_call();
----------------
We want to pass `_ArgTypes&&...` to prevent an additional copy on the way to the target function.


================
Comment at: include/functional:1656
+    typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+    // TODO: Should we forward small pods by value here?
+    return _Invoker::__call(f, _VSTD::forward<_ArgTypes>(args)...);
----------------
We should forward everything as perfectly as we can.


================
Comment at: include/functional:1729
+        unique_ptr<_Fp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
+        ::new (__hold.get()) _Fp(*static_cast<const _Fp*>(__src->large));
+        __dst->large = __hold.release();
----------------
`::new (static_cast<void*>(__hold.get())) _Fp(...)` just in case anybody is trying to hijack placement new.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55045/new/

https://reviews.llvm.org/D55045





More information about the libcxx-commits mailing list