diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-05-28 12:46:51 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-05-28 12:46:51 -0400 |
| commit | 3612806d5ea470f5dd2fb5a6e7f5be9de716a67e (patch) | |
| tree | 2f41f52b40059bf05013f30194201934c446864a /pktmpln.h | |
| parent | b9f23559d8bc36356ea0b6264c91d82dba3fb74d (diff) | |
pktmpln: first-pass, adds _1, _2, and _3
Diffstat (limited to 'pktmpln.h')
| -rw-r--r-- | pktmpln.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pktmpln.h b/pktmpln.h new file mode 100644 index 0000000..64000ef --- /dev/null +++ b/pktmpln.h @@ -0,0 +1,35 @@ +#ifndef PK_PKTMPLN_H +#define PK_PKTMPLN_H + +#if defined (__cplusplus) +#include <functional> +template<typename Ret, typename A1, typename B1> +struct pk_tmpln_1 { + using FuncType = std::function<Ret(A1)>; + FuncType func; + static Ret invoke(void *ptr, B1 b1) { + auto *self = static_cast<pk_tmpln_1*>(ptr); + return self->func(reinterpret_cast<A1>(b1)); + } +}; +template<typename Ret, typename A1, typename A2, typename B1, typename B2> +struct pk_tmpln_2 { + using FuncType = std::function<Ret(A1, A2)>; + FuncType func; + static Ret invoke(void *ptr, B1 b1, B2 b2) { + auto *self = static_cast<pk_tmpln_2*>(ptr); + return self->func(reinterpret_cast<A1>(b1), reinterpret_cast<A2>(b2)); + } +}; +template<typename Ret, typename A1, typename A2, typename A3, typename B1, typename B2, typename B3> +struct pk_tmpln_3 { + using FuncType = std::function<Ret(A1, A2, A3)>; + FuncType func; + static Ret invoke(void *ptr, B1 b1, B2 b2, B3 b3) { + auto *self = static_cast<pk_tmpln_3*>(ptr); + return self->func(reinterpret_cast<A1>(b1), reinterpret_cast<A2>(b2), reinterpret_cast<A3>(b3)); + } +}; +#endif + +#endif /* PK_PKTMPLN_H */ |
