[libcxx-commits] [libcxx] Speed up std::invoke() compile times (~60%-85% reduction) (PR #213403)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 2 07:56:29 PST 2026


================
@@ -74,21 +78,16 @@ template <class, class... _Args>
 struct __invoke_result_impl {};
 
 template <class... _Args>
-struct __invoke_result_impl<__void_t<decltype(__builtin_invoke(std::declval<_Args>()...))>, _Args...> {
-  using type _LIBCPP_NODEBUG = decltype(__builtin_invoke(std::declval<_Args>()...));
-};
-
-template <class... _Args>
-using __invoke_result _LIBCPP_NODEBUG = __invoke_result_impl<void, _Args...>;
+using __invoke_result_t _LIBCPP_NODEBUG =
+    decltype(__builtin_invoke(reinterpret_cast<_Args&&>(static_cast<int&&>(0))...));
----------------
higher-performance wrote:

I remember it was surprising and not negligible, or I wouldn't have done it. I'd have to set up my testing benchmarking setup again to check each individual thing, which is a bit of a pain. It's only 1 line... could we move forward with this?

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


More information about the libcxx-commits mailing list