From e33fe14f5b4bc2596842dffe718f8af080674251 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 10 Jun 2019 08:28:39 -0700 Subject: [PATCH] Simplify visit --- include/fmt/core.h | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 4b1bf3b5..194b3373 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -213,17 +213,6 @@ using std_string_view = std::experimental::basic_string_view; template struct std_string_view {}; #endif -#if (__cplusplus >= 201703L || \ - (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \ - __cpp_lib_is_invocable >= 201703L -template -using invoke_result_t = std::invoke_result_t; -#else -// An implementation of invoke_result for pre-C++17. -template -using invoke_result_t = typename std::result_of::type; -#endif - // Casts nonnegative integer to unsigned. template FMT_CONSTEXPR typename std::make_unsigned::type to_unsigned(Int value) { @@ -855,8 +844,8 @@ template class basic_format_arg { const T& value); template - friend FMT_CONSTEXPR internal::invoke_result_t visit_format_arg( - Visitor&& vis, const basic_format_arg& arg); + friend FMT_CONSTEXPR auto visit_format_arg( + Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)); friend class basic_format_args; friend class internal::arg_map; @@ -898,8 +887,8 @@ struct monostate {}; \endrst */ template -FMT_CONSTEXPR internal::invoke_result_t visit_format_arg( - Visitor&& vis, const basic_format_arg& arg) { +FMT_CONSTEXPR auto visit_format_arg( + Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)) { using char_type = typename Context::char_type; switch (arg.type_) { case internal::none_type: @@ -937,8 +926,8 @@ FMT_CONSTEXPR internal::invoke_result_t visit_format_arg( } template -FMT_DEPRECATED FMT_CONSTEXPR internal::invoke_result_t visit( - Visitor&& vis, const basic_format_arg& arg) { +FMT_DEPRECATED FMT_CONSTEXPR auto visit( + Visitor&& vis, const basic_format_arg& arg) -> decltype(vis(0)) { return visit_format_arg(std::forward(vis), arg); }