Browse Source

Math: make Deg/Rad conversion constructors noexcept as well.

Because why not.
pull/638/head
Vladimír Vondruš 2 years ago
parent
commit
e6c709bd43
  1. 8
      src/Magnum/Math/Angle.h
  2. 3
      src/Magnum/Math/Test/AngleTest.cpp

8
src/Magnum/Math/Angle.h

@ -136,7 +136,7 @@ template<class T> class Deg: public Unit<Deg, T> {
* @f]
* @m_keyword{degrees(),GLSL degrees(),}
*/
constexpr /*implicit*/ Deg(Unit<Rad, T> value);
constexpr /*implicit*/ Deg(Unit<Rad, T> value) noexcept;
};
/* Unlike STL, where there's e.g. std::literals::string_literals with both
@ -225,7 +225,7 @@ template<class T> class Rad: public Unit<Rad, T> {
* @f]
* @m_keyword{radians(),GLSL radians(),}
*/
constexpr /*implicit*/ Rad(Unit<Deg, T> value);
constexpr /*implicit*/ Rad(Unit<Deg, T> value) noexcept;
};
/* Unlike STL, where there's e.g. std::literals::string_literals with both
@ -266,8 +266,8 @@ constexpr Rad<Float> operator "" _radf(long double value) { return Rad<Float>(Fl
}}
template<class T> constexpr Deg<T>::Deg(Unit<Rad, T> value): Unit<Math::Deg, T>(T(180)*T(value)/Math::Constants<T>::pi()) {}
template<class T> constexpr Rad<T>::Rad(Unit<Deg, T> value): Unit<Math::Rad, T>(T(value)*Math::Constants<T>::pi()/T(180)) {}
template<class T> constexpr Deg<T>::Deg(Unit<Rad, T> value) noexcept: Unit<Math::Deg, T>(T(180)*T(value)/Math::Constants<T>::pi()) {}
template<class T> constexpr Rad<T>::Rad(Unit<Deg, T> value) noexcept: Unit<Math::Rad, T>(T(value)*Math::Constants<T>::pi()/T(180)) {}
#ifndef CORRADE_SINGLES_NO_DEBUG
/** @debugoperator{Rad} */

3
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<Deg, Rad>::value);
CORRADE_VERIFY(std::is_nothrow_constructible<Radd, Degd>::value);
}
void AngleTest::debugDeg() {

Loading…
Cancel
Save