C++20 compat: use invoke_result_t for C++17 and up (#36016)

C++20 removes std::result_of in favor of std::invoke_result[_t], which was added in C++17. Android builds gRPC with C++20, but gRPC still supports source languages before C++17, so use `#if __cplusplus` to select between std::result_of or std::invoke_result[_t].

Closes #36016

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36016 from rprichard:cxx20-compat 00b89a2ff4
PiperOrigin-RevId: 635929424
pull/36597/head^2
Ryan Prichard 6 months ago committed by Copybara-Service
parent f4ac0a3093
commit 3d1275ec17
  1. 8
      src/core/lib/promise/detail/promise_like.h

@ -76,7 +76,13 @@ class PromiseLike<void>;
template <typename F> template <typename F>
class PromiseLike<F, absl::enable_if_t<!std::is_void< class PromiseLike<F, absl::enable_if_t<!std::is_void<
typename std::result_of<F()>::type>::value>> { #if (defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703L) || \
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
std::invoke_result_t<F>
#else
typename std::result_of<F()>::type
#endif
>::value>> {
private: private:
GPR_NO_UNIQUE_ADDRESS RemoveCVRef<F> f_; GPR_NO_UNIQUE_ADDRESS RemoveCVRef<F> f_;

Loading…
Cancel
Save