From a63395f21975a6a09971ef914cf3d45ad28e62de Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Thu, 6 Feb 2025 18:30:35 +0100 Subject: [PATCH] better fields --- include/examples/KeepAlivePacket.h | 2 +- include/sp/protocol/Field.h | 7 ++++++- include/sp/protocol/MessageBase.h | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/examples/KeepAlivePacket.h b/include/examples/KeepAlivePacket.h index 9bad650..dfa45ae 100644 --- a/include/examples/KeepAlivePacket.h +++ b/include/examples/KeepAlivePacket.h @@ -8,6 +8,6 @@ enum KeepAlivePacketFields { KeepAliveId = 0 }; -using KeepAliveFields = sp::FieldsBuilder::Type; +using KeepAliveFields = std::tuple; DeclarePacket(KeepAlive); \ No newline at end of file diff --git a/include/sp/protocol/Field.h b/include/sp/protocol/Field.h index ca385fe..54ed84a 100644 --- a/include/sp/protocol/Field.h +++ b/include/sp/protocol/Field.h @@ -71,10 +71,15 @@ struct FieldsBuilder<> { using Type = std::tuple<>; }; +template +struct FieldsBuilder> { + using Type = typename FieldsBuilder::Type; +}; + + template struct FieldsBuilder { using Type = sp::tuple_cat_t>, typename FieldsBuilder::Type>; }; - } // namespace sp diff --git a/include/sp/protocol/MessageBase.h b/include/sp/protocol/MessageBase.h index b29bd8a..f7decc9 100644 --- a/include/sp/protocol/MessageBase.h +++ b/include/sp/protocol/MessageBase.h @@ -54,7 +54,7 @@ struct MessageImplParsedOptions, TOptions...> : pu template struct MessageImplParsedOptions, TOptions...> : public MessageImplParsedOptions { static const bool HasFieldsImpl = true; - using Fields = TFields; + using Fields = typename FieldsBuilder::Type; };