From 3612806d5ea470f5dd2fb5a6e7f5be9de716a67e Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Wed, 28 May 2025 12:46:51 -0400 Subject: pktmpln: first-pass, adds _1, _2, and _3 --- pktmpln.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pktmpln.h (limited to 'pktmpln.h') 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 +template +struct pk_tmpln_1 { + using FuncType = std::function; + FuncType func; + static Ret invoke(void *ptr, B1 b1) { + auto *self = static_cast(ptr); + return self->func(reinterpret_cast(b1)); + } +}; +template +struct pk_tmpln_2 { + using FuncType = std::function; + FuncType func; + static Ret invoke(void *ptr, B1 b1, B2 b2) { + auto *self = static_cast(ptr); + return self->func(reinterpret_cast(b1), reinterpret_cast(b2)); + } +}; +template +struct pk_tmpln_3 { + using FuncType = std::function; + FuncType func; + static Ret invoke(void *ptr, B1 b1, B2 b2, B3 b3) { + auto *self = static_cast(ptr); + return self->func(reinterpret_cast(b1), reinterpret_cast(b2), reinterpret_cast(b3)); + } +}; +#endif + +#endif /* PK_PKTMPLN_H */ -- cgit v1.2.3