diff --git a/include/dap/typeof.h b/include/dap/typeof.h index 803bb8d..43c9289 100644 --- a/include/dap/typeof.h +++ b/include/dap/typeof.h @@ -164,7 +164,7 @@ M member_type(M T::*); bool TypeOf::deserializeFields(const Deserializer* fd, void* obj) { \ using StructTy = STRUCT; \ (void)sizeof(StructTy); /* avoid unused 'using' warning */ \ - for (auto field : std::initializer_list{__VA_ARGS__}) { \ + for (auto& field : std::initializer_list{__VA_ARGS__}) { \ if (!fd->field(field.name, [&](Deserializer* d) { \ auto ptr = reinterpret_cast(obj) + field.offset; \ return field.type->deserialize(d, ptr); \ @@ -177,7 +177,7 @@ M member_type(M T::*); bool TypeOf::serializeFields(FieldSerializer* fs, const void* obj) {\ using StructTy = STRUCT; \ (void)sizeof(StructTy); /* avoid unused 'using' warning */ \ - for (auto field : std::initializer_list{__VA_ARGS__}) { \ + for (auto& field : std::initializer_list{__VA_ARGS__}) { \ if (!fs->field(field.name, [&](Serializer* s) { \ auto ptr = reinterpret_cast(obj) + field.offset; \ return field.type->serialize(s, ptr); \