aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2023-09-11 18:36:11 +1000
committerAnthony Towns <aj@erisian.com.au>2023-09-14 10:25:26 +1000
commit5e5c8f86b60a8018e8801fb44bbe56ce97d9deef (patch)
treee5e5dcce04fc23c66f9b0102899eca89bb70a7aa /src/serialize.h
parent33203f59b482bddfe0bbe7d497cb8731ce8334a4 (diff)
serialize: add SER_PARAMS_OPFUNC
Diffstat (limited to 'src/serialize.h')
-rw-r--r--src/serialize.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/serialize.h b/src/serialize.h
index 7e4788a5ca..04b29d1ded 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -1192,4 +1192,17 @@ static auto WithParams(const Params& params, T&& t)
return ParamsWrapper<Params, T>{params, t};
}
+/**
+ * Helper macro for SerParams structs
+ *
+ * Allows you define SerParams instances and then apply them directly
+ * to an object via function call syntax, eg:
+ *
+ * constexpr SerParams FOO{....};
+ * ss << FOO(obj);
+ */
+#define SER_PARAMS_OPFUNC \
+ template <typename T> \
+ auto operator()(T&& t) const { return WithParams(*this, t); }
+
#endif // BITCOIN_SERIALIZE_H