From 9dc582c6bc1be98e16bc1bed066566c8aabab08b Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 25 Nov 2023 13:30:08 +0100 Subject: [PATCH] Add emplace set functions for tuple --- example/config.curl | 2 ++ m-tuple.h | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 example/config.curl diff --git a/example/config.curl b/example/config.curl new file mode 100644 index 00000000..b6c62f2e --- /dev/null +++ b/example/config.curl @@ -0,0 +1,2 @@ +-DHAVE_CURL=1 +-lcurl diff --git a/m-tuple.h b/m-tuple.h index 21ee43a8..55edc1ae 100644 --- a/m-tuple.h +++ b/m-tuple.h @@ -134,6 +134,7 @@ namespace m_lib { M_TUPL3_DEFINE_CLEAR(name, __VA_ARGS__) \ M_TUPL3_DEFINE_GETTER_FIELD(name, __VA_ARGS__) \ M_TUPL3_DEFINE_SETTER_FIELD(name, __VA_ARGS__) \ + M_TUPL3_DEFINE_EMPLACE_FIELD(name, __VA_ARGS__) \ M_TUPL3_IF_ONE(CMP, __VA_ARGS__)(M_TUPL3_DEFINE_CMP(name, __VA_ARGS__),) \ M_TUPL3_IF_ALL(CMP, __VA_ARGS__)(M_TUPL3_DEFINE_CMP_ORDER(name, __VA_ARGS__),) \ M_TUPL3_DEFINE_CMP_FIELD(name, __VA_ARGS__) \ @@ -348,6 +349,25 @@ namespace m_lib { } +/* Define the EMPLACE_field methods for all params. */ +#define M_TUPL3_DEFINE_EMPLACE_FIELD(name, ...) \ + M_REDUCE3(M_TUPL3_DEFINE_EMPLACE_FIELD_PROTO, M_TUPL3_DEFINE_EMPLACE_G, name, __VA_ARGS__) + +#define M_TUPL3_DEFINE_EMPLACE_G(a, b) a b + +#define M_TUPL3_DEFINE_EMPLACE_FIELD_PROTO(name, id, a) \ + M_EMPLACE_QUEUE_DEF(M_TUPL3_GET_FIELD a, M_F(name, _ct), M_C3(name, _emplace_, M_TUPL3_GET_FIELD a), M_TUPL3_GET_OPLIST a, M_TUPL3_EMPLACE_DEF) + +#define M_TUPL3_EMPLACE_DEF(name, name_t, function_name, oplist, init_func, exp_emplace_type) \ + M_INLINE void \ + function_name(name_t v \ + M_EMPLACE_LIST_TYPE_VAR(a, exp_emplace_type) ) \ + { \ + M_CALL_CLEAR(oplist, v->name); \ + M_EMPLACE_CALL_FUNC(a, init_func, oplist, v->name, exp_emplace_type); \ + } + + /* Define the CMP method by calling CMP methods for all params. */ #define M_TUPL3_DEFINE_CMP(name, ...) \ M_INLINE int M_F(name, _cmp)(M_F(name,_ct) const e1 , \