better fields

This commit is contained in:
2025-02-06 18:30:35 +01:00
parent 8ecfb95167
commit a63395f219
3 changed files with 8 additions and 3 deletions

View File

@@ -8,6 +8,6 @@ enum KeepAlivePacketFields {
KeepAliveId = 0 KeepAliveId = 0
}; };
using KeepAliveFields = sp::FieldsBuilder<std::uint64_t>::Type; using KeepAliveFields = std::tuple<std::uint64_t /*KeepAliveId*/>;
DeclarePacket(KeepAlive); DeclarePacket(KeepAlive);

View File

@@ -71,10 +71,15 @@ struct FieldsBuilder<> {
using Type = std::tuple<>; using Type = std::tuple<>;
}; };
template<typename... TFields>
struct FieldsBuilder<std::tuple<TFields...>> {
using Type = typename FieldsBuilder<TFields...>::Type;
};
template <typename TField, typename... TFields> template <typename TField, typename... TFields>
struct FieldsBuilder<TField, TFields...> { struct FieldsBuilder<TField, TFields...> {
using Type = sp::tuple_cat_t<std::tuple<Field<TField>>, typename FieldsBuilder<TFields...>::Type>; using Type = sp::tuple_cat_t<std::tuple<Field<TField>>, typename FieldsBuilder<TFields...>::Type>;
}; };
} // namespace sp } // namespace sp

View File

@@ -54,7 +54,7 @@ struct MessageImplParsedOptions<option::DispatchImpl<TActual>, TOptions...> : pu
template <typename TFields, typename... TOptions> template <typename TFields, typename... TOptions>
struct MessageImplParsedOptions<option::FieldsImpl<TFields>, TOptions...> : public MessageImplParsedOptions<TOptions...> { struct MessageImplParsedOptions<option::FieldsImpl<TFields>, TOptions...> : public MessageImplParsedOptions<TOptions...> {
static const bool HasFieldsImpl = true; static const bool HasFieldsImpl = true;
using Fields = TFields; using Fields = typename FieldsBuilder<TFields>::Type;
}; };