From 77dc8cfc45e7bae1d1219bac2e06bac87eb8c6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 21 May 2020 21:39:19 +0200 Subject: [PATCH] Really fix use of std::result_of when invoke_result is available Closes #1934 --- .../benchmark/detail/catch_complete_invoke.hpp | 6 +++--- include/internal/benchmark/detail/catch_measure.hpp | 2 +- .../benchmark/detail/catch_run_for_at_least.hpp | 6 +++--- include/internal/benchmark/detail/catch_timing.hpp | 4 ++-- include/internal/catch_meta.hpp | 12 ++++++------ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/internal/benchmark/detail/catch_complete_invoke.hpp b/include/internal/benchmark/detail/catch_complete_invoke.hpp index b87e95db..f6a083d4 100644 --- a/include/internal/benchmark/detail/catch_complete_invoke.hpp +++ b/include/internal/benchmark/detail/catch_complete_invoke.hpp @@ -46,15 +46,15 @@ namespace Catch { // invoke and not return void :( template - CompleteType_t> complete_invoke(Fun&& fun, Args&&... args) { - return CompleteInvoker>::invoke(std::forward(fun), std::forward(args)...); + CompleteType_t> complete_invoke(Fun&& fun, Args&&... args) { + return CompleteInvoker>::invoke(std::forward(fun), std::forward(args)...); } const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; } // namespace Detail template - Detail::CompleteType_t> user_code(Fun&& fun) { + Detail::CompleteType_t> user_code(Fun&& fun) { CATCH_TRY{ return Detail::complete_invoke(std::forward(fun)); } CATCH_CATCH_ALL{ diff --git a/include/internal/benchmark/detail/catch_measure.hpp b/include/internal/benchmark/detail/catch_measure.hpp index 62ed2809..c3bd35fa 100644 --- a/include/internal/benchmark/detail/catch_measure.hpp +++ b/include/internal/benchmark/detail/catch_measure.hpp @@ -21,7 +21,7 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure(Fun&& fun, Args&&... args) { + TimingOf measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); auto&& r = Detail::complete_invoke(fun, std::forward(args)...); auto end = Clock::now(); diff --git a/include/internal/benchmark/detail/catch_run_for_at_least.hpp b/include/internal/benchmark/detail/catch_run_for_at_least.hpp index a41c6b46..339507ba 100644 --- a/include/internal/benchmark/detail/catch_run_for_at_least.hpp +++ b/include/internal/benchmark/detail/catch_run_for_at_least.hpp @@ -25,11 +25,11 @@ namespace Catch { namespace Benchmark { namespace Detail { template - TimingOf measure_one(Fun&& fun, int iters, std::false_type) { + TimingOf measure_one(Fun&& fun, int iters, std::false_type) { return Detail::measure(fun, iters); } template - TimingOf measure_one(Fun&& fun, int iters, std::true_type) { + TimingOf measure_one(Fun&& fun, int iters, std::true_type) { Detail::ChronometerModel meter; auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); @@ -46,7 +46,7 @@ namespace Catch { }; template - TimingOf)> run_for_at_least(ClockDuration how_long, int seed, Fun&& fun) { + TimingOf> run_for_at_least(ClockDuration how_long, int seed, Fun&& fun) { auto iters = seed; while (iters < (1 << 30)) { auto&& Timing = measure_one(fun, iters, is_callable()); diff --git a/include/internal/benchmark/detail/catch_timing.hpp b/include/internal/benchmark/detail/catch_timing.hpp index d4141d2b..fc24886a 100644 --- a/include/internal/benchmark/detail/catch_timing.hpp +++ b/include/internal/benchmark/detail/catch_timing.hpp @@ -25,8 +25,8 @@ namespace Catch { Result result; int iterations; }; - template - using TimingOf = Timing, Detail::CompleteType_t>>; + template + using TimingOf = Timing, Detail::CompleteType_t>>; } // namespace Benchmark } // namespace Catch diff --git a/include/internal/catch_meta.hpp b/include/internal/catch_meta.hpp index 4eca7efc..b54cecc2 100644 --- a/include/internal/catch_meta.hpp +++ b/include/internal/catch_meta.hpp @@ -32,13 +32,13 @@ namespace Catch { #if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703 // std::result_of is deprecated in C++17 and removed in C++20. Hence, it is - // replaced with std::invoke_result here. Also *_t format is preferred over - // typename *::type format. - template - using FunctionReturnType = std::remove_reference_t>>; + // replaced with std::invoke_result here. + template + using FunctionReturnType = std::remove_reference_t>>; #else - template - using FunctionReturnType = typename std::remove_reference::type>::type>::type; + // Keep ::type here because we still support C++11 + template + using FunctionReturnType = typename std::remove_reference::type>::type>::type; #endif } // namespace Catch