result_of -> invoke_result_t

This commit is contained in:
Victor Zverovich 2019-05-31 08:54:32 -07:00
parent 49f78a427b
commit 406e632bd1

View File

@ -215,18 +215,15 @@ using std_string_view = std::experimental::basic_string_view<Char>;
template <typename T> struct std_string_view {}; template <typename T> struct std_string_view {};
#endif #endif
template <typename> struct result_of;
#if (__cplusplus >= 201703L || \ #if (__cplusplus >= 201703L || \
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \ (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \
__cpp_lib_is_invocable >= 201703L __cpp_lib_is_invocable >= 201703L
template <typename F, typename... Args> template <typename F, typename... Args>
struct result_of<F(Args...)> : std::invoke_result<F, Args...> {}; using invoke_result_t = std::invoke_result_t<F, Args...>;
#else #else
// A workaround for gcc 4.4 that doesn't allow F to be a reference. // An implementation of invoke_result for pre-C++17.
template <typename F, typename... Args> template <typename F, typename... Args>
struct result_of<F(Args...)> using invoke_result_t = typename std::result_of<F(Args...)>::type;
: std::result_of<typename std::remove_reference<F>::type(Args...)> {};
#endif #endif
// Casts nonnegative integer to unsigned. // Casts nonnegative integer to unsigned.
@ -906,8 +903,8 @@ template <typename Context> class basic_format_arg {
const T& value); const T& value);
template <typename Visitor, typename Ctx> template <typename Visitor, typename Ctx>
friend FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type friend FMT_CONSTEXPR internal::invoke_result_t<Visitor, int> visit_format_arg(
visit_format_arg(Visitor&& vis, const basic_format_arg<Ctx>& arg); Visitor&& vis, const basic_format_arg<Ctx>& arg);
friend class basic_format_args<Context>; friend class basic_format_args<Context>;
friend class internal::arg_map<Context>; friend class internal::arg_map<Context>;
@ -949,7 +946,7 @@ struct monostate {};
\endrst \endrst
*/ */
template <typename Visitor, typename Context> template <typename Visitor, typename Context>
FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type visit_format_arg( FMT_CONSTEXPR internal::invoke_result_t<Visitor, int> visit_format_arg(
Visitor&& vis, const basic_format_arg<Context>& arg) { Visitor&& vis, const basic_format_arg<Context>& arg) {
typedef typename Context::char_type char_type; typedef typename Context::char_type char_type;
switch (arg.type_) { switch (arg.type_) {
@ -988,8 +985,8 @@ FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type visit_format_arg(
} }
template <typename Visitor, typename Context> template <typename Visitor, typename Context>
FMT_DEPRECATED FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type FMT_DEPRECATED FMT_CONSTEXPR internal::invoke_result_t<Visitor, int> visit(
visit(Visitor&& vis, const basic_format_arg<Context>& arg) { Visitor&& vis, const basic_format_arg<Context>& arg) {
return visit_format_arg(std::forward<Visitor>(vis), arg); return visit_format_arg(std::forward<Visitor>(vis), arg);
} }