From 3588527a99e12d3e474899b83dd51cfc9e6dbde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Mon, 18 Sep 2023 19:31:40 -0400 Subject: [PATCH] [ci] Workaround MSVC issue --- include/avnd/binding/vst3/component.hpp | 4 ++-- include/avnd/binding/vst3/controller.hpp | 14 ++++++++------ include/avnd/concepts/generic.hpp | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/include/avnd/binding/vst3/component.hpp b/include/avnd/binding/vst3/component.hpp index 040245ea..abaec244 100644 --- a/include/avnd/binding/vst3/component.hpp +++ b/include/avnd/binding/vst3/component.hpp @@ -331,7 +331,7 @@ struct Component final { avnd::parameter_input_introspection::for_nth_raw( effect.inputs(), id, [&](C& ctl) { - if_possible(ctl.value = avnd::map_control_from_01(value)); + assign_if_assignable(ctl.value, avnd::map_control_from_01(value)); }); }; } @@ -527,7 +527,7 @@ struct Component final double param = 0.f; if(streamer.readDouble(param) == false) return false; - if_possible(field.value = avnd::map_control_from_01(param)); + assign_if_assignable(field.value, avnd::map_control_from_01(param)); return true; }); diff --git a/include/avnd/binding/vst3/controller.hpp b/include/avnd/binding/vst3/controller.hpp index c8dc79dc..b09fbd3e 100644 --- a/include/avnd/binding/vst3/controller.hpp +++ b/include/avnd/binding/vst3/controller.hpp @@ -16,7 +16,6 @@ namespace stv3 { - template class Controller final : public stv3::ControllerCommon @@ -109,7 +108,7 @@ class Controller final if constexpr(avnd::has_inputs) { inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&](C& field) { - if_possible(res = avnd::map_control_from_01_to_fp(valueNormalized)); + assign_if_assignable(res, avnd::map_control_from_01_to_fp(valueNormalized)); }); } return res; @@ -122,7 +121,7 @@ class Controller final if constexpr(avnd::has_inputs) { inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&](C& field) { - if_possible(res = avnd::map_control_from_fp_to_01(plainValue)); + assign_if_assignable(res, avnd::map_control_from_fp_to_01(plainValue)); }); } return res; @@ -135,7 +134,7 @@ class Controller final if constexpr(avnd::has_inputs) { inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&](C& field) { - if_possible(res = avnd::map_control_to_01(field)); + assign_if_assignable(res, avnd::map_control_to_01(field)); }); } return res; @@ -149,7 +148,7 @@ class Controller final if constexpr(avnd::has_inputs) { inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&](C& field) { - if_possible(field.value = avnd::map_control_from_01(value)); + assign_if_assignable(field.value, avnd::map_control_from_01(value)); }); } @@ -171,10 +170,13 @@ class Controller final { bool ok = inputs_info_t::for_all_unless( this->inputs_mirror, [&](C& field) -> bool { + double param = 0.f; if(streamer.readDouble(param) == false) return false; - if_possible(field.value = avnd::map_control_from_01(param)); + + assign_if_assignable(field.value, avnd::map_control_from_01(param)); + return true; }); diff --git a/include/avnd/concepts/generic.hpp b/include/avnd/concepts/generic.hpp index 0b82f519..38dbb29a 100644 --- a/include/avnd/concepts/generic.hpp +++ b/include/avnd/concepts/generic.hpp @@ -26,6 +26,21 @@ namespace avnd } \ () +#if defined(_MSC_VER) +#define assign_if_assignable(dst, src) \ + do \ + if constexpr(requires { src; }) \ + { \ + using val_type = std::add_lvalue_reference_t; \ + using ret_type = decltype(src); \ + if constexpr(std::is_assignable_v) \ + dst = src; \ + } \ + while(0) +#else +#define assign_if_assignable(dst, src) if_possible(dst = src); +#endif + // Very generic concepts template concept vector_ish = requires(T t) {