Skip to content

Commit

Permalink
[ci] Workaround MSVC issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Sep 18, 2023
1 parent 0b8771f commit 3588527
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/avnd/binding/vst3/component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ struct Component final
{
avnd::parameter_input_introspection<T>::for_nth_raw(
effect.inputs(), id, [&]<typename C>(C& ctl) {
if_possible(ctl.value = avnd::map_control_from_01<C>(value));
assign_if_assignable(ctl.value, avnd::map_control_from_01<C>(value));
});
};
}
Expand Down Expand Up @@ -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<C>(param));
assign_if_assignable(field.value, avnd::map_control_from_01<C>(param));
return true;
});

Expand Down
14 changes: 8 additions & 6 deletions include/avnd/binding/vst3/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace stv3
{

template <typename T>
class Controller final
: public stv3::ControllerCommon
Expand Down Expand Up @@ -109,7 +108,7 @@ class Controller final
if constexpr(avnd::has_inputs<T>)
{
inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&]<typename C>(C& field) {
if_possible(res = avnd::map_control_from_01_to_fp<C>(valueNormalized));
assign_if_assignable(res, avnd::map_control_from_01_to_fp<C>(valueNormalized));
});
}
return res;
Expand All @@ -122,7 +121,7 @@ class Controller final
if constexpr(avnd::has_inputs<T>)
{
inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&]<typename C>(C& field) {
if_possible(res = avnd::map_control_from_fp_to_01<C>(plainValue));
assign_if_assignable(res, avnd::map_control_from_fp_to_01<C>(plainValue));
});
}
return res;
Expand All @@ -135,7 +134,7 @@ class Controller final
if constexpr(avnd::has_inputs<T>)
{
inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&]<typename C>(C& field) {
if_possible(res = avnd::map_control_to_01(field));
assign_if_assignable(res, avnd::map_control_to_01(field));
});
}
return res;
Expand All @@ -149,7 +148,7 @@ class Controller final
if constexpr(avnd::has_inputs<T>)
{
inputs_info_t::for_nth_raw(this->inputs_mirror, tag, [&]<typename C>(C& field) {
if_possible(field.value = avnd::map_control_from_01<C>(value));
assign_if_assignable(field.value, avnd::map_control_from_01<C>(value));
});
}

Expand All @@ -171,10 +170,13 @@ class Controller final
{
bool ok = inputs_info_t::for_all_unless(
this->inputs_mirror, [&]<typename C>(C& field) -> bool {

double param = 0.f;
if(streamer.readDouble(param) == false)
return false;
if_possible(field.value = avnd::map_control_from_01<C>(param));

assign_if_assignable(field.value, avnd::map_control_from_01<C>(param));

return true;
});

Expand Down
15 changes: 15 additions & 0 deletions include/avnd/concepts/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<decltype(dst)>; \
using ret_type = decltype(src); \
if constexpr(std::is_assignable_v<val_type, ret_type>) \
dst = src; \
} \
while(0)
#else
#define assign_if_assignable(dst, src) if_possible(dst = src);
#endif

// Very generic concepts
template <typename T>
concept vector_ish = requires(T t) {
Expand Down

0 comments on commit 3588527

Please sign in to comment.