summaryrefslogtreecommitdiff
path: root/absl/meta
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2020-11-20 09:52:55 -0800
committerGravatar Derek Mauro <dmauro@google.com>2020-11-20 13:05:26 -0500
commite19260fd7dbef881492fd73891e0be5bd4a09b95 (patch)
treee83b1fda901b1a079b6a22330d9b775b87369c87 /absl/meta
parent4fd9a1ec5077daac14eeee05df931d658ec0b7b8 (diff)
Export of internal Abseil changes
-- 1f91ba7fcb79244fce1fe448c1d31fb5b0580584 by Derek Mauro <dmauro@google.com>: Internal change PiperOrigin-RevId: 343511158 -- 8dcd61fed44f4e56044aa4a899cc3124117fa21f by Abseil Team <absl-team@google.com>: refactors result_of so it doesn't unnecessarily break in C++20 mode std::result_of was deprecated in C++17 and removed in C++20. This CL adds an implementation detail so it transparently continues to work when external users turn up to C++20 or later. The implementation is derived from C++17's specification of result_of [depr.meta.types][1]. [1]: https://timsong-cpp.github.io/cppwp/n4659/depr.meta.types Fixes #649 PiperOrigin-RevId: 343395432 GitOrigin-RevId: 1f91ba7fcb79244fce1fe448c1d31fb5b0580584 Change-Id: Id5d9c55dc7547737bade48a15f2f5740f414d811
Diffstat (limited to 'absl/meta')
-rw-r--r--absl/meta/type_traits.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h
index 75689bb6..d5cb5f3b 100644
--- a/absl/meta/type_traits.h
+++ b/absl/meta/type_traits.h
@@ -610,8 +610,22 @@ using common_type_t = typename std::common_type<T...>::type;
template <typename T>
using underlying_type_t = typename std::underlying_type<T>::type;
-template <typename T>
-using result_of_t = typename std::result_of<T>::type;
+
+namespace type_traits_internal {
+
+#if __cplusplus >= 201703L
+// std::result_of is deprecated (C++17) or removed (C++20)
+template<typename> struct result_of;
+template<typename F, typename... Args>
+struct result_of<F(Args...)> : std::invoke_result<F, Args...> {};
+#else
+template<typename F> using result_of = std::result_of<F>;
+#endif
+
+} // namespace type_traits_internal
+
+template<typename F>
+using result_of_t = typename type_traits_internal::result_of<F>::type;
namespace type_traits_internal {
// In MSVC we can't probe std::hash or stdext::hash because it triggers a