Commit 9687393c authored by Håkan Wennlöf's avatar Håkan Wennlöf Committed by Simon Spannagel
Browse files

REshuffled and removed extraneous if-statement after disucssion.

Shouldn't affect anything much

(cherry picked from commit aeb0755f)
parent 60d81267
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -27,17 +27,15 @@ namespace allpix {
           out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) {
            throw std::overflow_error("unit conversion overflows the type");
        }
        if constexpr(!std::is_integral_v<T>) {
            return static_cast<T>(out);
        } else {
            // If the input is an integral value: check so that it doesn't have decimals after applying the unit
        if constexpr(std::is_integral_v<T>) {
            // If the input is an integral value: check so that it doesn't have decimals after applying the unit
            if(out != static_cast<T>(out)) {
                throw LogicError("Cannot use integer value with non-integer internal unit; the combination " +
                                 std::to_string(inp) + " " + str + " is invalid.");
            }
            return static_cast<T>(out);
            }
        } else {
            return static_cast<T>(out);
        }
    }