diff --git a/include/ignition/math/Interval.hh b/include/ignition/math/Interval.hh index fb0229b10..115db95dc 100644 --- a/include/ignition/math/Interval.hh +++ b/include/ignition/math/Interval.hh @@ -51,11 +51,14 @@ namespace ignition /// \brief Constructor /// \param[in] _leftValue leftmost interval value - /// \param[in] _leftClosed whether the interval is left-closed or not + /// \param[in] _leftClosed whether the interval is + /// left-closed or not /// \param[in] _rightValue rightmost interval value - /// \param[in] _rightClosed whether the interval is right-closed or not - public: Interval(T _leftValue, bool _leftClosed, - T _rightValue, bool _rightClosed) + /// \param[in] _rightClosed whether the interval + /// is right-closed or not + public: constexpr Interval( + T _leftValue, bool _leftClosed, + T _rightValue, bool _rightClosed) : leftValue(std::move(_leftValue)), rightValue(std::move(_rightValue)), leftClosed(_leftClosed), @@ -67,7 +70,8 @@ namespace ignition /// \param[in] _leftValue leftmost interval value /// \param[in] _rightValue rightmost interval value /// \return the open interval - public: static Interval Open(T _leftValue, T _rightValue) + public: static constexpr Interval + Open(T _leftValue, T _rightValue) { return Interval( std::move(_leftValue), false, @@ -78,7 +82,8 @@ namespace ignition /// \param[in] _leftValue leftmost interval value /// \param[in] _rightValue rightmost interval value /// \return the left-closed interval - public: static Interval LeftClosed(T _leftValue, T _rightValue) + public: static constexpr Interval + LeftClosed(T _leftValue, T _rightValue) { return Interval( std::move(_leftValue), true, @@ -89,7 +94,8 @@ namespace ignition /// \param[in] _leftValue leftmost interval value /// \param[in] _rightValue rightmost interval value /// \return the left-closed interval - public: static Interval RightClosed(T _leftValue, T _rightValue) + public: static constexpr Interval + RightClosed(T _leftValue, T _rightValue) { return Interval( std::move(_leftValue), false, @@ -100,7 +106,8 @@ namespace ignition /// \param[in] _leftValue leftmost interval value /// \param[in] _rightValue rightmost interval value /// \return the closed interval - public: static Interval Closed(T _leftValue, T _rightValue) + public: static constexpr Interval + Closed(T _leftValue, T _rightValue) { return Interval{ std::move(_leftValue), true, @@ -276,7 +283,7 @@ namespace ignition namespace detail { template - const Interval gUnboundedInterval = + constexpr Interval gUnboundedInterval = Interval::Open(-std::numeric_limits::infinity(), std::numeric_limits::infinity()); } // namespace detail diff --git a/include/ignition/math/Region3.hh b/include/ignition/math/Region3.hh index 5d5bb4f8d..339a9d91b 100644 --- a/include/ignition/math/Region3.hh +++ b/include/ignition/math/Region3.hh @@ -60,7 +60,8 @@ namespace ignition /// \param[in] _ix x-axis interval /// \param[in] _iy y-axis interval /// \param[in] _iz z-axis interval - public: Region3(Interval _ix, Interval _iy, Interval _iz) + public: constexpr Region3( + Interval _ix, Interval _iy, Interval _iz) : ix(std::move(_ix)), iy(std::move(_iy)), iz(std::move(_iz)) { } @@ -74,7 +75,7 @@ namespace ignition /// \param[in] _zRight righmost z-axis interval value /// \return the (`_xLeft`, `_xRight`) ✕ (`_yLeft`, `_yRight`) /// ✕ (`_zLeft`, `_zRight`) open region - public: static Region3 Open( + public: static constexpr Region3 Open( T _xLeft, T _yLeft, T _zLeft, T _xRight, T _yRight, T _zRight) { @@ -92,7 +93,7 @@ namespace ignition /// \param[in] _zRight righmost z-axis interval value /// \return the [`_xLeft`, `_xRight`] ✕ [`_yLeft`, `_yRight`] /// ✕ [`_zLeft`, `_zRight`] closed region - public: static Region3 Closed( + public: static constexpr Region3 Closed( T _xLeft, T _yLeft, T _zLeft, T _xRight, T _yRight, T _zRight) { @@ -188,7 +189,7 @@ namespace ignition namespace detail { template - const Region3 gUnboundedRegion3( + constexpr Region3 gUnboundedRegion3( Interval::Open(-std::numeric_limits::infinity(), std::numeric_limits::infinity()), Interval::Open(-std::numeric_limits::infinity(),