Skip to content

Commit

Permalink
result_of -> invoke_result_t
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed May 31, 2019
1 parent 49f78a4 commit 406e632
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,15 @@ using std_string_view = std::experimental::basic_string_view<Char>;
template <typename T> struct std_string_view {};
#endif

template <typename> struct result_of;

#if (__cplusplus >= 201703L || \
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \
__cpp_lib_is_invocable >= 201703L
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
// 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>
struct result_of<F(Args...)>
: std::result_of<typename std::remove_reference<F>::type(Args...)> {};
using invoke_result_t = typename std::result_of<F(Args...)>::type;
#endif

// Casts nonnegative integer to unsigned.
Expand Down Expand Up @@ -906,8 +903,8 @@ template <typename Context> class basic_format_arg {
const T& value);

template <typename Visitor, typename Ctx>
friend FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
visit_format_arg(Visitor&& vis, const basic_format_arg<Ctx>& arg);
friend FMT_CONSTEXPR internal::invoke_result_t<Visitor, int> visit_format_arg(
Visitor&& vis, const basic_format_arg<Ctx>& arg);

friend class basic_format_args<Context>;
friend class internal::arg_map<Context>;
Expand Down Expand Up @@ -949,7 +946,7 @@ struct monostate {};
\endrst
*/
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) {
typedef typename Context::char_type char_type;
switch (arg.type_) {
Expand Down Expand Up @@ -988,8 +985,8 @@ FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type visit_format_arg(
}

template <typename Visitor, typename Context>
FMT_DEPRECATED FMT_CONSTEXPR typename internal::result_of<Visitor(int)>::type
visit(Visitor&& vis, const basic_format_arg<Context>& arg) {
FMT_DEPRECATED FMT_CONSTEXPR internal::invoke_result_t<Visitor, int> visit(
Visitor&& vis, const basic_format_arg<Context>& arg) {
return visit_format_arg(std::forward<Visitor>(vis), arg);
}

Expand Down

0 comments on commit 406e632

Please sign in to comment.