diff --git a/src/idl_gen_cpp.cpp b/src/idl_gen_cpp.cpp index 0e8bb28de..8977c6b0f 100644 --- a/src/idl_gen_cpp.cpp +++ b/src/idl_gen_cpp.cpp @@ -1928,6 +1928,8 @@ class CppGenerator : public BaseGenerator { code_ += " }"; if (parser_.opts.mutable_buffer) { + auto mut_field_type = GenTypeGet(field.value.type, " ", "", " &", true); + code_.SetValue("FIELD_TYPE", mut_field_type); if (is_scalar) { code_.SetValue("ARG", GenTypeBasic(field.value.type, true)); code_.SetValue("FIELD_VALUE", diff --git a/tests/monster_test.bfbs b/tests/monster_test.bfbs index a27bafc61..d5a1aadaa 100644 Binary files a/tests/monster_test.bfbs and b/tests/monster_test.bfbs differ diff --git a/tests/monster_test_generated.h b/tests/monster_test_generated.h index b1fac7463..57966f5fc 100644 --- a/tests/monster_test_generated.h +++ b/tests/monster_test_generated.h @@ -243,7 +243,7 @@ MANUALLY_ALIGNED_STRUCT(16) Vec3 FLATBUFFERS_FINAL_CLASS { const Test &test3() const { return test3_; } - const Test &mutable_test3() { + Test &mutable_test3() { return test3_; } };