diff --git a/include/mp/proxy-types.h b/include/mp/proxy-types.h index e4f5835..5766911 100644 --- a/include/mp/proxy-types.h +++ b/include/mp/proxy-types.h @@ -955,22 +955,26 @@ void CustomBuildField(TypeList local_type, template void PassField(TypeList, ServerContext& server_context, const Fn& fn, Args&&... args) { - InvokeContext& invoke_context = server_context; - boost::optional> param; const auto& params = server_context.call_context.getParams(); const auto& input = Make(params); - bool want = input.want(); - if (want) { - MaybeReadField(std::integral_constant(), TypeList(), invoke_context, input, - Emplace(param)); - if (!param) param.emplace(); + + if (!input.want()) { + fn.invoke(server_context, std::forward(args)..., nullptr); + server_context.call_context.getResults(); + return; } - fn.invoke(server_context, std::forward(args)..., param ? &*param : nullptr); + + InvokeContext& invoke_context = server_context; + Decay param; + + MaybeReadField(std::integral_constant(), TypeList(), invoke_context, input, + Emplace(param)); + + fn.invoke(server_context, std::forward(args)..., ¶m); + auto&& results = server_context.call_context.getResults(); - if (want) { - MaybeBuildField(std::integral_constant(), TypeList(), invoke_context, - Make(results), *param); - } + MaybeBuildField(std::integral_constant(), TypeList(), invoke_context, + Make(results), param); } template