diff --git a/src/App/ColorModel.cpp b/src/App/ColorModel.cpp index bd7845f603..27375cad9d 100644 --- a/src/App/ColorModel.cpp +++ b/src/App/ColorModel.cpp @@ -106,14 +106,13 @@ ColorField& ColorField::operator = (const ColorField &rclCF) void ColorField::set (const ColorModel &rclModel, float fMin, float fMax, std::size_t usCt) { - fMin = std::min(fMin, fMax); - fMax = std::max(fMin, fMax); - if (fMax <= fMin) { + auto bounds = std::minmax(fMin, fMax); + if (bounds.first <= bounds.second) { throw Base::ValueError("Maximum must be higher than minimum"); } - this->fMin = fMin; - this->fMax = fMax; + this->fMin = bounds.first; + this->fMax = bounds.second; colorModel = rclModel; ctColors = std::max(usCt, colorModel.getCountColors()); rebuild(); @@ -212,14 +211,13 @@ std::vector ColorGradient::getColorModelNames() const void ColorGradient::set (float fMin, float fMax, std::size_t usCt, TStyle tS, bool bOG) { - fMin = std::min(fMin, fMax); - fMax = std::max(fMin, fMax); - if (fMax <= fMin) { + auto bounds = std::minmax(fMin, fMax); + if (bounds.first <= bounds.second) { throw Base::ValueError("Maximum must be higher than minimum"); } - _fMin = fMin; - _fMax = fMax; + _fMin = bounds.first; + _fMax = bounds.second; ctColors = std::max(usCt, getMinColors()); tStyle = tS; outsideGrayed = bOG;