Skip to content

Commit 29225c6

Browse files
committed
[struct_pack] fix stack overflow in serialize when there is many struct member
1 parent ef4af57 commit 29225c6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

include/ylt/struct_pack/packer.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,9 @@ class packer {
139139
}
140140

141141
template <std::size_t size_type, uint64_t version,
142-
std::uint64_t parent_tag = 0, typename First, typename... Args>
143-
constexpr void STRUCT_PACK_INLINE serialize_many(const First &first_item,
144-
const Args &...items) {
145-
serialize_one<size_type, version, parent_tag>(first_item);
146-
if constexpr (sizeof...(items) > 0) {
147-
serialize_many<size_type, version, parent_tag>(items...);
148-
}
142+
std::uint64_t parent_tag = 0, typename... Args>
143+
constexpr void STRUCT_PACK_INLINE serialize_many(const Args &...items) {
144+
(serialize_one<size_type, version, parent_tag>(items), ...);
149145
}
150146
constexpr void STRUCT_PACK_INLINE write_padding(std::size_t sz) {
151147
if (sz > 0) {

0 commit comments

Comments
 (0)