Skip to content

Commit

Permalink
Fix MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Jan 20, 2024
1 parent 0e54eb5 commit 8a40654
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/sfizz/SynthMessagingHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,31 @@ class MessagingHelper {
// haven't found a nice way to the same with pointer-to-member function.
// TODO: could do something with the c++14 compatible `invoke` maybe?

template <class T, class M, class... Args>
void set(T M::*member, Args&&... args)
{
dispatch(
static_cast<void (MessagingHelper::*)(T&, Args && ...)>(&MessagingHelper::set),
member,
std::forward<Args>(args)...);
}

// MSVC require this because it finds T M::* and T Voice::* ambiguous in the overload
// resolution of `reply`, so we "disable" the reply/set dispatching for Voice and
// TriggerEvent since they're read-only components.
template<class M>
using DispatchedType = typename std::enable_if<
!std::is_same<M, Voice>::value && !std::is_same<M, TriggerEvent>::value, void>::type ;

template <class T, class M, class... Args>
DispatchedType<M> reply(T M::*member, Args&&... args)
{
dispatch(
static_cast<void (MessagingHelper::*)(const T&, Args&&...)>(&MessagingHelper::reply),
member,
std::forward<Args>(args)...);
}


template <class T, class F, class... Args>
void dispatch(F&& f, T FilterDescription::*member, Args&&... args)
Expand Down Expand Up @@ -408,24 +433,6 @@ class MessagingHelper {
inv::invoke(std::forward<F>(f), this, (*region).*member, std::forward<Args>(args)...);
}

template <class T, class M, class... Args>
void set(T M::*member, Args&&... args)
{
dispatch(
static_cast<void (MessagingHelper::*)(T&, Args && ...)>(&MessagingHelper::set),
member,
std::forward<Args>(args)...);
}

template <class T, class M, class... Args>
void reply(T M::*member, Args&&... args)
{
dispatch(
static_cast<void (MessagingHelper::*)(const T&, Args&&...)>(&MessagingHelper::reply),
member,
std::forward<Args>(args)...);
}

template <class T, class F, class... Args>
void dispatch(F&& f, T EQDescription::*member, Args&&... args)
{
Expand Down

0 comments on commit 8a40654

Please sign in to comment.