Skip to content
Snippets Groups Projects
Verified Commit b6eae08e authored by Martin Stump's avatar Martin Stump
Browse files

Add noexcept specifier


Signed-off-by: default avatarMartin Stump <martin.stump@mercedes-benz.com>
parent 110f5181
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,7 @@ namespace details ...@@ -43,7 +43,7 @@ namespace details
{ {
template <typename T, std::enable_if_t<std::is_arithmetic_v<T>, bool> = true> template <typename T, std::enable_if_t<std::is_arithmetic_v<T>, bool> = true>
constexpr int signum(const T value) constexpr int signum(const T value) noexcept
{ {
return (T{0} < value) - (value < T{0}); return (T{0} < value) - (value < T{0});
} }
...@@ -62,7 +62,7 @@ inline constexpr auto kDefaultEps = MANTLE_API_DEFAULT_EPS; ...@@ -62,7 +62,7 @@ inline constexpr auto kDefaultEps = MANTLE_API_DEFAULT_EPS;
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true> template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) noexcept
{ {
// Handle NaN. // Handle NaN.
// NaN should never be equal to anything. // NaN should never be equal to anything.
...@@ -103,7 +103,7 @@ constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = static_ca ...@@ -103,7 +103,7 @@ constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = static_ca
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true> template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) noexcept
{ {
if (lhs > rhs) if (lhs > rhs)
{ {
...@@ -121,7 +121,7 @@ constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = static ...@@ -121,7 +121,7 @@ constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = static
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true> template <typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = static_cast<T>(kDefaultEps)) noexcept
{ {
if (lhs < rhs) if (lhs < rhs)
{ {
...@@ -139,7 +139,7 @@ constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = static_ca ...@@ -139,7 +139,7 @@ constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = static_ca
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true> template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true>
constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) noexcept
{ {
return AlmostEqual(lhs(), rhs(), epsilon()); return AlmostEqual(lhs(), rhs(), epsilon());
} }
...@@ -152,7 +152,7 @@ constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = T{kDefaul ...@@ -152,7 +152,7 @@ constexpr bool AlmostEqual(const T lhs, const T rhs, const T epsilon = T{kDefaul
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true> template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true>
constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) noexcept
{ {
return GreaterOrEqual(lhs(), rhs(), epsilon()); return GreaterOrEqual(lhs(), rhs(), epsilon());
} }
...@@ -165,7 +165,7 @@ constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = T{kDef ...@@ -165,7 +165,7 @@ constexpr bool GreaterOrEqual(const T lhs, const T rhs, const T epsilon = T{kDef
/// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps. /// \param[in] epsilon The epsilon for floating-point comparison. Defaults to kDefaultEps.
/// ///
template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true> template <typename T, std::enable_if_t<units::traits::is_unit_t<T>::value, bool> = true>
constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) constexpr bool LessOrEqual(const T lhs, const T rhs, const T epsilon = T{kDefaultEps}) noexcept
{ {
return LessOrEqual(lhs(), rhs(), epsilon()); return LessOrEqual(lhs(), rhs(), epsilon());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment