WiimoteEmu: Add a static_assert in DesiredExtensionState to keep variant alternative order consistent.
This commit is contained in:
parent
0d0734e083
commit
3f92f86de1
|
@ -17,21 +17,42 @@
|
|||
#include "Core/HW/WiimoteEmu/Extension/TaTaCon.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/Turntable.h"
|
||||
#include "Core/HW/WiimoteEmu/Extension/UDrawTablet.h"
|
||||
#include "Core/HW/WiimoteEmu/ExtensionPort.h"
|
||||
|
||||
namespace WiimoteEmu
|
||||
{
|
||||
struct DesiredExtensionState
|
||||
{
|
||||
private:
|
||||
template <ExtensionNumber N, typename T>
|
||||
struct ExtNumTypePair
|
||||
{
|
||||
static constexpr ExtensionNumber ext_num = N;
|
||||
using ext_type = T;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
struct ExtDataImpl
|
||||
{
|
||||
using type = std::variant<std::monostate, typename Ts::DesiredState...>;
|
||||
using type = std::variant<std::monostate, typename Ts::ext_type::DesiredState...>;
|
||||
|
||||
static_assert((std::is_same_v<std::variant_alternative_t<Ts::ext_num, type>,
|
||||
typename Ts::ext_type::DesiredState> &&
|
||||
...),
|
||||
"Please use ExtensionNumber enum order for DTM file index consistency.");
|
||||
};
|
||||
|
||||
public:
|
||||
using ExtensionData = ExtDataImpl<Nunchuk, Classic, Guitar, Drums, Turntable, UDrawTablet,
|
||||
DrawsomeTablet, TaTaCon, Shinkansen>::type;
|
||||
using ExtensionData =
|
||||
ExtDataImpl<ExtNumTypePair<ExtensionNumber::NUNCHUK, Nunchuk>,
|
||||
ExtNumTypePair<ExtensionNumber::CLASSIC, Classic>,
|
||||
ExtNumTypePair<ExtensionNumber::GUITAR, Guitar>,
|
||||
ExtNumTypePair<ExtensionNumber::DRUMS, Drums>,
|
||||
ExtNumTypePair<ExtensionNumber::TURNTABLE, Turntable>,
|
||||
ExtNumTypePair<ExtensionNumber::UDRAW_TABLET, UDrawTablet>,
|
||||
ExtNumTypePair<ExtensionNumber::DRAWSOME_TABLET, DrawsomeTablet>,
|
||||
ExtNumTypePair<ExtensionNumber::TATACON, TaTaCon>,
|
||||
ExtNumTypePair<ExtensionNumber::SHINKANSEN, Shinkansen>>::type;
|
||||
|
||||
ExtensionData data = std::monostate{};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue