mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 20:14:23 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user