catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Really fix use of std::result_of when invoke_result is available
- Commit
77dc8cfc45e7bae1d1219bac2e06bac87eb8c6b1- Author
- Martin Hořeňovský ·
- Parents
ddc9f4c61df4
Changes
include/internal/benchmark/detail/catch_complete_invoke.hpp | 6 +++--- include/internal/benchmark/detail/catch_measure.hpp | 2 +- include/internal/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 <typename Fun, typename... Args> - CompleteType_t<FunctionReturnType<Fun(Args...)>> complete_invoke(Fun&& fun, Args&&... args) { - return CompleteInvoker<FunctionReturnType<Fun(Args...)>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); + CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) { + return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(std::forward<Fun>(fun), std::forward<Args>(args)...); } const std::string benchmarkErrorMsg = "a benchmark failed to run successfully"; } // namespace Detail template <typename Fun> - Detail::CompleteType_t<FunctionReturnType<Fun()>> user_code(Fun&& fun) { + Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) { CATCH_TRY{ return Detail::complete_invoke(std::forward<Fun>(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 <typename Clock, typename Fun, typename... Args> - TimingOf<Clock, Fun(Args...)> measure(Fun&& fun, Args&&... args) { + TimingOf<Clock, Fun, Args...> measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); auto&& r = Detail::complete_invoke(fun, std::forward<Args>(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 <typename Clock, typename Fun> - TimingOf<Clock, Fun(int)> measure_one(Fun&& fun, int iters, std::false_type) { + TimingOf<Clock, Fun, int> measure_one(Fun&& fun, int iters, std::false_type) { return Detail::measure<Clock>(fun, iters); } template <typename Clock, typename Fun> - TimingOf<Clock, Fun(Chronometer)> measure_one(Fun&& fun, int iters, std::true_type) { + TimingOf<Clock, Fun, Chronometer> measure_one(Fun&& fun, int iters, std::true_type) { Detail::ChronometerModel<Clock> meter; auto&& result = Detail::complete_invoke(fun, Chronometer(meter, iters)); @@ -46,7 +46,7 @@ namespace Catch { }; template <typename Clock, typename Fun> - TimingOf<Clock, Fun(run_for_at_least_argument_t<Clock, Fun>)> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { + TimingOf<Clock, Fun, run_for_at_least_argument_t<Clock, Fun>> run_for_at_least(ClockDuration<Clock> how_long, int seed, Fun&& fun) { auto iters = seed; while (iters < (1 << 30)) { auto&& Timing = measure_one<Clock>(fun, iters, is_callable<Fun(Chronometer)>()); 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 <typename Clock, typename Sig> - using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Sig>>>; + template <typename Clock, typename Func, typename... Args> + using TimingOf = Timing<ClockDuration<Clock>, Detail::CompleteType_t<FunctionReturnType<Func, Args...>>>; } // 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 <typename Func, typename U> - using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U>>>; + // replaced with std::invoke_result here. + template <typename Func, typename... U> + using FunctionReturnType = std::remove_reference_t<std::remove_cv_t<std::invoke_result_t<Func, U...>>>; #else - template <typename Func, typename U> - using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U)>::type>::type>::type; + // Keep ::type here because we still support C++11 + template <typename Func, typename... U> + using FunctionReturnType = typename std::remove_reference<typename std::remove_cv<typename std::result_of<Func(U...)>::type>::type>::type; #endif } // namespace Catch