From 8471a66a83e08c1be0d6f97565e6654a241ab6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 7 Jan 2025 20:02:59 +0100 Subject: [PATCH] singles: include the time types in MagnumMath. Because why not, they're not that big and they're very useful, especially in combination with the std::chrono compatibility. --- doc/namespaces.dox | 10 ++++++---- src/Magnum/Math/Time.h | 4 ++++ src/singles/MagnumMath.hpp | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/doc/namespaces.dox b/doc/namespaces.dox index 42b2edd5d..a302028f3 100644 --- a/doc/namespaces.dox +++ b/doc/namespaces.dox @@ -113,10 +113,12 @@ more information. @endcode @par If you need the deinlined symbols to be exported from a shared library, - @cpp #define MAGNUM_EXPORT @ce as appropriate. In addition, contents of the - @ref GlmIntegration and @ref EigenIntegration libraries except for the - @ref Magnum/EigenIntegration/DynamicMatrixIntegration.h header are included - as well --- opt-in by specifying either + @cpp #define MAGNUM_EXPORT @ce as appropriate. The STL compatibility bits + for time types are included as well --- opt-in with + @cpp #define MAGNUM_MATH_STL_COMPATIBILITY @ce before including the file. + Contents of the @ref GlmIntegration and @ref EigenIntegration libraries + except for the @ref Magnum/EigenIntegration/DynamicMatrixIntegration.h + can be opted in by specifying either @cpp #define MAGNUM_MATH_GLM_INTEGRATION @ce or @cpp #define MAGNUM_MATH_EIGEN_INTEGRATION @ce before including the file. Including it multiple times with different macros defined works as well. diff --git a/src/Magnum/Math/Time.h b/src/Magnum/Math/Time.h index a3461681c..b71a34ff1 100644 --- a/src/Magnum/Math/Time.h +++ b/src/Magnum/Math/Time.h @@ -31,7 +31,9 @@ * @m_since_latest */ +#ifndef CORRADE_SINGLES_NO_DEBUG #include +#endif #include "Magnum/Magnum.h" #include "Magnum/visibility.h" @@ -396,6 +398,7 @@ template template constexpr Nanoseconds::Nanoseconds(Unit template constexpr Seconds::Seconds(Unit value) noexcept: Unit{T(static_cast(U(value))/1000000000.0l)} {} +#ifndef CORRADE_SINGLES_NO_DEBUG /** * @debugoperator{Nanoseconds} * @m_since_latest @@ -407,6 +410,7 @@ MAGNUM_EXPORT Utility::Debug& operator<<(Utility::Debug& debug, const Unit& value); +#endif }} diff --git a/src/singles/MagnumMath.hpp b/src/singles/MagnumMath.hpp index e08349d3c..5da0e4048 100644 --- a/src/singles/MagnumMath.hpp +++ b/src/singles/MagnumMath.hpp @@ -24,9 +24,11 @@ #include If you need the deinlined symbols to be exported from a shared library, - `#define MAGNUM_EXPORT` as appropriate. In addition, contents of the - GlmIntegration and EigenIntegration libraries are included as well --- - opt-in by specifying either `#define MAGNUM_MATH_GLM_INTEGRATION` or + `#define MAGNUM_EXPORT` as appropriate. The STL compatibility bits for time + types are included as well --- opt-in with + `#define MAGNUM_MATH_STL_COMPATIBILITY` before including the file. Contents + of the GlmIntegration and EigenIntegration libraries can be opted in by + specifying either `#define MAGNUM_MATH_GLM_INTEGRATION` or `#define MAGNUM_MATH_EIGEN_INTEGRATION` before including the file. Including it multiple times with different macros defined works as well. @@ -309,6 +311,8 @@ typedef Math::Range1D Range1Di; typedef Math::Range2D Range2Di; typedef Math::Range3D Range3Di; typedef Math::Frustum Frustum; +typedef Math::Nanoseconds Nanoseconds; +typedef Math::Seconds Seconds; typedef Math::Vector2 Vector2h; typedef Math::Vector3 Vector3h; typedef Math::Vector4 Vector4h; @@ -397,6 +401,7 @@ typedef Math::Frustum Frustumd; #include "Magnum/Math/RectangularMatrix.h" #include "Magnum/Math/Swizzle.h" #include "Magnum/Math/Tags.h" +#include "Magnum/Math/Time.h" #include "Magnum/Math/TypeTraits.h" #include "Magnum/Math/Unit.h" #include "Magnum/Math/Vector.h" @@ -408,6 +413,10 @@ typedef Math::Frustum Frustumd; #include "Magnum/Math/Algorithms/KahanSum.h" #include "Magnum/Math/Algorithms/Qr.h" //#include "Magnum/Math/Algorithms/Svd.h" // TODO needs Optional and Triple +#ifdef MAGNUM_MATH_STL_COMPATIBILITY +// {{includes}} +#include "Magnum/Math/TimeStl.h" +#endif #ifdef MAGNUM_MATH_GLM_INTEGRATION // {{includes}} #include "Magnum/GlmIntegration/Integration.h" @@ -424,4 +433,5 @@ typedef Math::Frustum Frustumd; // {{ includes }} #include "Magnum/Math/Functions.cpp" #include "Magnum/Math/Packing.cpp" +/* Time.cpp is just debug output operators, not included */ #endif