Loading src/core/utils/unit.tpp +14 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ #include "text.h" #include <cmath> namespace allpix { /** * @throws std::overflow_error If the converted unit overflows the requested type Loading @@ -24,6 +26,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } Loading @@ -34,6 +39,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getSingleInverse(T inp, std::string str) { Loading @@ -42,6 +50,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getInverse(T inp, const std::string& str) { Loading @@ -50,6 +61,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } Loading Loading
src/core/utils/unit.tpp +14 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ #include "text.h" #include <cmath> namespace allpix { /** * @throws std::overflow_error If the converted unit overflows the requested type Loading @@ -24,6 +26,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } Loading @@ -34,6 +39,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getSingleInverse(T inp, std::string str) { Loading @@ -42,6 +50,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getInverse(T inp, const std::string& str) { Loading @@ -50,6 +61,9 @@ 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>) { out = std::round(out); } return static_cast<T>(out); } Loading