diff --git a/compiler/extensions/cpp/freemarker/CompoundField.inc.ftl b/compiler/extensions/cpp/freemarker/CompoundField.inc.ftl index c2b2f1703..88ea4bae4 100644 --- a/compiler/extensions/cpp/freemarker/CompoundField.inc.ftl +++ b/compiler/extensions/cpp/freemarker/CompoundField.inc.ftl @@ -25,7 +25,7 @@ ${I}if (in.readBool()) ${I}{ <@compound_read_field_inner field, compoundName, indent + 1/> ${I}} -${I} + ${I}return ::zserio::NullOpt; <#else> <@compound_read_field_inner field, compoundName, indent/> @@ -547,10 +547,10 @@ ${I}<@field_member_name field/>(::std::move(other.<@field_member_name field/>))< ${I}m_objectChoice(::std::forward(value)) <#else> ${I}<@field_member_name field/>(<#rt> - <#if field.isSimpleType> - <@field_argument_name field/><#t> - <#else> + <#if !field.isSimpleType || field.optional??> ::std::forward(<@field_argument_name field/>)<#t> + <#else> + <@field_argument_name field/><#t> <#lt>)<#if hasNext>,