File indexing completed on 2025-01-30 10:02:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef CATCH_COMPLETE_INVOKE_HPP_INCLUDED
0011 #define CATCH_COMPLETE_INVOKE_HPP_INCLUDED
0012
0013 #include <catch2/internal/catch_meta.hpp>
0014 #include <catch2/internal/catch_move_and_forward.hpp>
0015
0016 namespace Catch {
0017 namespace Benchmark {
0018 namespace Detail {
0019 template <typename T>
0020 struct CompleteType { using type = T; };
0021 template <>
0022 struct CompleteType<void> { struct type {}; };
0023
0024 template <typename T>
0025 using CompleteType_t = typename CompleteType<T>::type;
0026
0027 template <typename Result>
0028 struct CompleteInvoker {
0029 template <typename Fun, typename... Args>
0030 static Result invoke(Fun&& fun, Args&&... args) {
0031 return CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
0032 }
0033 };
0034 template <>
0035 struct CompleteInvoker<void> {
0036 template <typename Fun, typename... Args>
0037 static CompleteType_t<void> invoke(Fun&& fun, Args&&... args) {
0038 CATCH_FORWARD(fun)(CATCH_FORWARD(args)...);
0039 return {};
0040 }
0041 };
0042
0043
0044 template <typename Fun, typename... Args>
0045 CompleteType_t<FunctionReturnType<Fun, Args...>> complete_invoke(Fun&& fun, Args&&... args) {
0046 return CompleteInvoker<FunctionReturnType<Fun, Args...>>::invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...);
0047 }
0048
0049 }
0050
0051 template <typename Fun>
0052 Detail::CompleteType_t<FunctionReturnType<Fun>> user_code(Fun&& fun) {
0053 return Detail::complete_invoke(CATCH_FORWARD(fun));
0054 }
0055 }
0056 }
0057
0058 #endif