18 #ifndef viskores_worklet_internal_Placeholders_h
19 #define viskores_worklet_internal_Placeholders_h
21 #include <viskoresstd/integer_sequence.h>
23 #include <type_traits>
29 namespace placeholders
38 template <
int ControlSignatureIndex>
48 struct FunctionSigArity;
49 template <
typename R,
typename... ArgTypes>
50 struct FunctionSigArity<R(ArgTypes...)>
52 static constexpr std::size_t value =
sizeof...(ArgTypes);
56 template <
int... Args>
57 auto DefaultSigGenerator(viskoresstd::integer_sequence<int, 0, Args...>) -> void (*)(Arg<Args>...);
71 using seq = viskoresstd::make_integer_sequence<int, Length + 1>;
72 using type =
typename std::remove_pointer<decltype(DefaultSigGenerator(seq{}))>::type;
75 struct DefaultExecSig<1>
77 using type = void(Arg<1>);
80 struct DefaultExecSig<2>
82 using type = void(Arg<1>, Arg<2>);
85 struct DefaultExecSig<3>
87 using type = void(Arg<1>, Arg<2>, Arg<3>);
90 struct DefaultExecSig<4>
92 using type = void(Arg<1>, Arg<2>, Arg<3>, Arg<4>);
95 template <
bool HasExecSig_,
typename Sig_>
98 static constexpr
bool HasExecSig = HasExecSig_;
102 template <typename U, typename S = decltype(std::declval<typename U::ExecutionSignature>())>
103 static ExecSigQuery<true, typename U::ExecutionSignature> get_exec_sig(
int);
105 template <
typename U>
106 static ExecSigQuery<false, void> get_exec_sig(...);
123 template <
typename WorkletType>
126 using cont_sig =
typename WorkletType::ControlSignature;
127 using cont_sig_info = viskores::placeholders::FunctionSigArity<cont_sig>;
129 using result = decltype(get_exec_sig<WorkletType>(0));
130 static constexpr
bool has_explicit_exec_sig = result::HasExecSig;
132 using ExecutionSignature =
typename std::conditional<
133 has_explicit_exec_sig,
134 typename result::Sig,
135 typename viskores::placeholders::DefaultExecSig<cont_sig_info::value>::type>::type;