From e6c709bd43cbc49c9f8224ec85ba9693a2a2cdd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 11 Feb 2024 21:11:57 +0100 Subject: [PATCH] Math: make Deg/Rad conversion constructors noexcept as well. Because why not. --- src/Magnum/Math/Angle.h | 8 ++++---- src/Magnum/Math/Test/AngleTest.cpp | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Math/Angle.h b/src/Magnum/Math/Angle.h index 1a16ba6bb..2a3c793e3 100644 --- a/src/Magnum/Math/Angle.h +++ b/src/Magnum/Math/Angle.h @@ -136,7 +136,7 @@ template class Deg: public Unit { * @f] * @m_keyword{degrees(),GLSL degrees(),} */ - constexpr /*implicit*/ Deg(Unit value); + constexpr /*implicit*/ Deg(Unit value) noexcept; }; /* Unlike STL, where there's e.g. std::literals::string_literals with both @@ -225,7 +225,7 @@ template class Rad: public Unit { * @f] * @m_keyword{radians(),GLSL radians(),} */ - constexpr /*implicit*/ Rad(Unit value); + constexpr /*implicit*/ Rad(Unit value) noexcept; }; /* Unlike STL, where there's e.g. std::literals::string_literals with both @@ -266,8 +266,8 @@ constexpr Rad operator "" _radf(long double value) { return Rad(Fl }} -template constexpr Deg::Deg(Unit value): Unit(T(180)*T(value)/Math::Constants::pi()) {} -template constexpr Rad::Rad(Unit value): Unit(T(value)*Math::Constants::pi()/T(180)) {} +template constexpr Deg::Deg(Unit value) noexcept: Unit(T(180)*T(value)/Math::Constants::pi()) {} +template constexpr Rad::Rad(Unit value) noexcept: Unit(T(value)*Math::Constants::pi()/T(180)) {} #ifndef CORRADE_SINGLES_NO_DEBUG /** @debugoperator{Rad} */ diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 5d4c9f181..f1764bb7b 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -334,6 +334,9 @@ void AngleTest::conversion() { constexpr Rad b = 90.0_degf; CORRADE_COMPARE(Float(b), 1.57079633f); + + CORRADE_VERIFY(std::is_nothrow_constructible::value); + CORRADE_VERIFY(std::is_nothrow_constructible::value); } void AngleTest::debugDeg() {