diff --git a/distrho/DistrhoDetails.hpp b/distrho/DistrhoDetails.hpp index 452a78ac..f72608f7 100644 --- a/distrho/DistrhoDetails.hpp +++ b/distrho/DistrhoDetails.hpp @@ -511,15 +511,6 @@ struct ParameterEnumerationValue { ParameterEnumerationValue(float v, const char* l) noexcept : value(v), label(l) {} - -#if __cplusplus >= 201703L - /** - Constructor using custom values, constexpr compatible variant. - */ - constexpr ParameterEnumerationValue(float v, const std::string_view& l) noexcept - : value(v), - label(l) {} -#endif }; /** @@ -714,29 +705,6 @@ struct Parameter { groupId(kPortGroupNone) {} #endif -#if __cplusplus >= 201703L - /** - Constructor for constexpr compatible data. - */ - constexpr Parameter(uint32_t h, - const std::string_view& n, - const std::string_view& sn, - const std::string_view& sym, - const std::string_view& u, - const std::string_view& desc) noexcept - : hints(h), - name(n), - shortName(sn), - symbol(sym), - unit(u), - description(desc), - ranges(), - enumValues(), - designation(kParameterDesignationNull), - midiCC(0), - groupId(kPortGroupNone) {} -#endif - /** Initialize a parameter for a specific designation. */ @@ -762,17 +730,57 @@ struct Parameter { break; } } -}; -#if __cplusplus >= 202001L /* TODO */ -/** - Bypass parameter definition in constexpr form. - */ -static constexpr const Parameter kParameterBypass = { - kParameterIsAutomatable|kParameterIsBoolean|kParameterIsInteger, - "Bypass", "Bypass", ParameterDesignationSymbols::bypass, "", "", {}, {}, 0, kPortGroupNone, + Parameter& operator=(Parameter& other) noexcept + { + hints = other.hints; + name = other.name; + shortName = other.shortName; + symbol = other.symbol; + unit = other.unit; + description = other.description; + ranges = other.ranges; + designation = other.designation; + midiCC = other.midiCC; + groupId = other.groupId; + + // enumValues needs special handling + enumValues.count = other.enumValues.count; + enumValues.restrictedMode = other.enumValues.restrictedMode; + enumValues.values = other.enumValues.values; + enumValues.deleteLater = other.enumValues.deleteLater; + + // make sure to not delete data twice + other.enumValues.deleteLater = false; + + return *this; + } + + Parameter& operator=(const Parameter& other) noexcept + { + hints = other.hints; + name = other.name; + shortName = other.shortName; + symbol = other.symbol; + unit = other.unit; + description = other.description; + ranges = other.ranges; + designation = other.designation; + midiCC = other.midiCC; + groupId = other.groupId; + + // make sure to not delete data twice + DISTRHO_SAFE_ASSERT_RETURN(other.enumValues.values == nullptr || !other.enumValues.deleteLater, *this); + + // enumValues needs special handling + enumValues.count = other.enumValues.count; + enumValues.restrictedMode = other.enumValues.restrictedMode; + enumValues.values = other.enumValues.values; + enumValues.deleteLater = other.enumValues.deleteLater; + + return *this; + } }; -#endif /** Port Group.@n diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index d61d5c43..08bd6bed 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -1,6 +1,6 @@ /* * DISTRHO Plugin Framework (DPF) - * Copyright (C) 2012-2023 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * Permission to use, copy, modify, and/or distribute this software for any purpose with * or without fee is hereby granted, provided that the above copyright notice and this @@ -22,10 +22,6 @@ #include -#if __cplusplus >= 201703L -# include -#endif - START_NAMESPACE_DISTRHO // ----------------------------------------------------------------------- @@ -91,16 +87,6 @@ public: _dup(strBuf); } - #if __cplusplus >= 201703L - /* - * constexpr compatible variant. - */ - explicit constexpr String(const std::string_view& strView) noexcept - : fBuffer(const_cast(strView.data())), - fBufferLen(strView.size()), - fBufferAlloc(false) {} - #endif - /* * Integer. */ @@ -695,11 +681,11 @@ public: "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; -#ifndef _MSC_VER + #ifndef _MSC_VER const std::size_t kTmpBufSize = std::min(d_nextPowerOf2(static_cast(dataSize/3)), 65536U); -#else + #else constexpr std::size_t kTmpBufSize = 65536U; -#endif + #endif const uchar* bytesToEncode((const uchar*)data);