From 61c9b563c2bad9d985ebef4286138a045c9333e3 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Sun, 3 Feb 2019 18:59:48 +0100 Subject: [PATCH] Replace 'std::result_of' by 'std::invoke_result' where possible (#1025) C++17 deprecated 'std::result_of' in favour of 'std::invoke_result' and will ban it outright in C++20. Therefore - implement 'internal::result_of' in terms of 'std::invoke_result' when compiling C++17 mode. - implement 'internal::result_of' in terms of 'std::result_of' when compiling in modes C++11 or C++14. Signed-off-by: Daniela Engert --- include/fmt/core.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 3a55f025..b1bf7b9c 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -217,11 +217,17 @@ typename std::add_rvalue_reference::type declval() FMT_NOEXCEPT; template struct result_of; -template struct result_of { - // A workaround for gcc 4.4 that doesn't allow F to be a reference. - typedef typename std::result_of::type( - Args...)>::type type; -}; +#if (__cplusplus >= 201703L || \ + (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \ + __cpp_lib_is_invocable >= 201703L +template +struct result_of : std::invoke_result {}; +#else +// A workaround for gcc 4.4 that doesn't allow F to be a reference. +template +struct result_of + : std::result_of::type(Args...)> {}; +#endif // Casts nonnegative integer to unsigned. template