From 31103d11a205b7704e4d9574864d1fe5ab121af1 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Tue, 17 Nov 2020 18:35:46 +0100 Subject: [PATCH] Add moves to the ModKey::Parameters --- src/sfizz/modulations/ModKey.cpp | 18 ++++++++++++++++++ src/sfizz/modulations/ModKey.h | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/sfizz/modulations/ModKey.cpp b/src/sfizz/modulations/ModKey.cpp index 051a4f8e..55807863 100644 --- a/src/sfizz/modulations/ModKey.cpp +++ b/src/sfizz/modulations/ModKey.cpp @@ -38,6 +38,24 @@ ModKey::Parameters& ModKey::Parameters::operator=(const Parameters& other) noexc return *this; } +ModKey::Parameters::Parameters(Parameters&& other) noexcept +{ + std::memcpy( + static_cast(this), + static_cast(&other), + sizeof(RawParameters)); +} + +ModKey::Parameters& ModKey::Parameters::operator=(Parameters&& other) noexcept +{ + if (this != &other) + std::memcpy( + static_cast(this), + static_cast(&other), + sizeof(RawParameters)); + return *this; +} + ModKey ModKey::createCC(uint16_t cc, uint8_t curve, uint8_t smooth, float step) { ModKey::Parameters p; diff --git a/src/sfizz/modulations/ModKey.h b/src/sfizz/modulations/ModKey.h index ce16c7a2..5653386f 100644 --- a/src/sfizz/modulations/ModKey.h +++ b/src/sfizz/modulations/ModKey.h @@ -59,8 +59,8 @@ public: Parameters(const Parameters& other) noexcept; Parameters& operator=(const Parameters& other) noexcept; - Parameters(Parameters&&) = delete; - Parameters &operator=(Parameters&&) = delete; + Parameters(Parameters&&) noexcept; + Parameters &operator=(Parameters&&) noexcept; bool operator==(const Parameters& other) const noexcept {