DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit 3fa74825770a9c500f9d07ad7cb2269fc1b73518
parent 2b557ed0166e2f3aef07254bb894a562900d09e5
Author: falkTX <falktx@falktx.com>
Date:   Mon, 24 Feb 2020 14:00:19 +0000

Add initializer list constructor to ParameterRanges class

Signed-off-by: falkTX <falktx@falktx.com>

Diffstat:
Mdistrho/DistrhoPlugin.hpp | 16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp @@ -189,7 +189,7 @@ struct ParameterRanges { float max; /** - Default constructor, using 0.0 as minimum, 1.0 as maximum and 0.0 as default. + Default constructor, using 0.0 as default, 0.0 as minimum, 1.0 as maximum. */ ParameterRanges() noexcept : def(0.0f), @@ -204,6 +204,20 @@ struct ParameterRanges { min(mn), max(mx) {} +#ifdef DISTRHO_PROPER_CPP11_SUPPORT + /** + Constructor using an initializer list, like `{ 0.0f, 0.0f, 1.0f }`. + @note You MUST use 3 variables in the list! + */ + ParameterRanges(const std::initializer_list<float>& il) + { + std::initializer_list<float>::iterator ilit = il.begin(); + def = *(ilit++); + min = *(ilit++); + max = *(ilit++); + } +#endif + /** Fix the default value within range. */