From e5cd777713dde12dde492858b73201b9b680a2ea Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 7 Dec 2020 23:49:25 +0100 Subject: [PATCH] Fix the templated visitor in Vst3MessageHandler Now it works as expected, since auto can't be initialized to multiple different values. --- src/common/communication/vst3.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index 4bc3d13b..24601100 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -179,17 +179,18 @@ class Vst3MessageHandler : public AdHocSocketHandler { // We do the visiting here using a templated lambda. This way we // always know for sure that the function returns the correct // type, and we can scrap a lot of boilerplate elsewhere. - const auto& response = std::visit( - [&](const T object) -> - typename T::Response { return callback(object); }, + std::visit( + [&](const T object) { + typename T::Response response = callback(object); + + if (logging) { + auto [logger, is_host_vst] = *logging; + logger.log_response(!is_host_vst, response); + } + + write_object(socket, response); + }, request); - - if (logging) { - auto [logger, is_host_vst] = *logging; - logger.log_response(!is_host_vst, response); - } - - write_object(socket, response); }; this->receive_multi(logging