From 08a6e7d957e651ee9063031a2ffd23abfa2648bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 2 May 2021 17:35:17 +0200 Subject: [PATCH] Math: explicit test that all types are trivially copyable. I saw some copy constructors here and there and wasn't sure. --- src/Magnum/Math/Test/AngleTest.cpp | 7 +++++++ src/Magnum/Math/Test/BezierTest.cpp | 5 +++++ src/Magnum/Math/Test/BoolVectorTest.cpp | 5 +++++ src/Magnum/Math/Test/ColorTest.cpp | 7 +++++++ src/Magnum/Math/Test/ComplexTest.cpp | 5 +++++ src/Magnum/Math/Test/CubicHermiteTest.cpp | 21 +++++++++++++++++-- src/Magnum/Math/Test/DualComplexTest.cpp | 5 +++++ src/Magnum/Math/Test/DualQuaternionTest.cpp | 5 +++++ src/Magnum/Math/Test/DualTest.cpp | 5 +++++ src/Magnum/Math/Test/FrustumTest.cpp | 5 +++++ src/Magnum/Math/Test/HalfTest.cpp | 5 +++++ src/Magnum/Math/Test/Matrix3Test.cpp | 5 +++++ src/Magnum/Math/Test/Matrix4Test.cpp | 5 +++++ src/Magnum/Math/Test/MatrixTest.cpp | 5 +++++ src/Magnum/Math/Test/QuaternionTest.cpp | 5 +++++ src/Magnum/Math/Test/RangeTest.cpp | 9 ++++++++ .../Math/Test/RectangularMatrixTest.cpp | 5 +++++ src/Magnum/Math/Test/UnitTest.cpp | 19 +++++++++++++++++ src/Magnum/Math/Test/Vector2Test.cpp | 5 +++++ src/Magnum/Math/Test/Vector3Test.cpp | 5 +++++ src/Magnum/Math/Test/Vector4Test.cpp | 5 +++++ src/Magnum/Math/Test/VectorTest.cpp | 5 +++++ 22 files changed, 146 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Math/Test/AngleTest.cpp b/src/Magnum/Math/Test/AngleTest.cpp index 2fce5c065..eead32ea1 100644 --- a/src/Magnum/Math/Test/AngleTest.cpp +++ b/src/Magnum/Math/Test/AngleTest.cpp @@ -33,6 +33,7 @@ #include #include #endif +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Angle.h" @@ -232,6 +233,12 @@ void AngleTest::constructCopy() { constexpr Radd d(b); CORRADE_COMPARE(d, b); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); diff --git a/src/Magnum/Math/Test/BezierTest.cpp b/src/Magnum/Math/Test/BezierTest.cpp index f87346dc8..84e74a536 100644 --- a/src/Magnum/Math/Test/BezierTest.cpp +++ b/src/Magnum/Math/Test/BezierTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Bezier.h" #include "Magnum/Math/CubicHermite.h" @@ -185,6 +186,10 @@ void BezierTest::constructCopy() { constexpr QuadraticBezier2D b{a}; CORRADE_COMPARE(b, (QuadraticBezier2D{Vector2{0.5f, 1.0f}, Vector2{1.1f, 0.3f}, Vector2{0.1f, 1.2f}})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/BoolVectorTest.cpp b/src/Magnum/Math/Test/BoolVectorTest.cpp index 36510bb0a..667b22424 100644 --- a/src/Magnum/Math/Test/BoolVectorTest.cpp +++ b/src/Magnum/Math/Test/BoolVectorTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/BoolVector.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -176,6 +177,10 @@ void BoolVectorTest::constructCopy() { constexpr BoolVector19 b(a); CORRADE_COMPARE(b, BoolVector19(0xa5, 0x5f, 0x07)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/ColorTest.cpp b/src/Magnum/Math/Test/ColorTest.cpp index 1f5a74348..08f83b0e0 100644 --- a/src/Magnum/Math/Test/ColorTest.cpp +++ b/src/Magnum/Math/Test/ColorTest.cpp @@ -32,6 +32,7 @@ #include #include #endif +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Color.h" #include "Magnum/Math/Half.h" @@ -429,6 +430,12 @@ void ColorTest::constructCopy() { Color4 d(c); CORRADE_COMPARE(d, Color4(1.0f, 0.5f, 0.75f, 0.25f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); diff --git a/src/Magnum/Math/Test/ComplexTest.cpp b/src/Magnum/Math/Test/ComplexTest.cpp index f6fe56efd..1b1a91f25 100644 --- a/src/Magnum/Math/Test/ComplexTest.cpp +++ b/src/Magnum/Math/Test/ComplexTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Complex.h" #include "Magnum/Math/Matrix3.h" @@ -253,6 +254,10 @@ void ComplexTest::constructCopy() { constexpr Complex b(a); CORRADE_COMPARE(b, Complex(2.5f, -5.0f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/CubicHermiteTest.cpp b/src/Magnum/Math/Test/CubicHermiteTest.cpp index fa0394f63..5505e6de7 100644 --- a/src/Magnum/Math/Test/CubicHermiteTest.cpp +++ b/src/Magnum/Math/Test/CubicHermiteTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Bezier.h" #include "Magnum/Math/CubicHermite.h" @@ -588,6 +589,10 @@ void CubicHermiteTest::constructCopyScalar() { CORRADE_COMPARE(b, (CubicHermite1D{2.0f, -2.0f, -0.5f})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } @@ -598,6 +603,10 @@ void CubicHermiteTest::constructCopyVector() { CORRADE_COMPARE(b, (CubicHermite2D{{1.0f, 2.0f}, {1.5f, -2.0f}, {3.0f, -0.5f}})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } @@ -608,6 +617,10 @@ void CubicHermiteTest::constructCopyComplex() { CORRADE_COMPARE(b, (CubicHermiteComplex{{1.0f, 2.0f}, {1.5f, -2.0f}, {3.0f, -0.5f}})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } @@ -624,8 +637,12 @@ void CubicHermiteTest::constructCopyQuaternion() { {{1.5f, -2.0f, 0.1f}, 1.1f}, {{3.0f, -0.5f, 1.2f}, 0.3f}})); - CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); - CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif + CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); + CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } void CubicHermiteTest::dataScalar() { diff --git a/src/Magnum/Math/Test/DualComplexTest.cpp b/src/Magnum/Math/Test/DualComplexTest.cpp index 7acf807d5..7ab00ea04 100644 --- a/src/Magnum/Math/Test/DualComplexTest.cpp +++ b/src/Magnum/Math/Test/DualComplexTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/DualComplex.h" #include "Magnum/Math/DualQuaternion.h" @@ -246,6 +247,10 @@ void DualComplexTest::constructCopy() { DualComplex b(a); CORRADE_COMPARE(b, DualComplex({-1.0f, 2.5f}, {3.0f, -7.5f})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/DualQuaternionTest.cpp b/src/Magnum/Math/Test/DualQuaternionTest.cpp index 95c941c5a..9379c3ee2 100644 --- a/src/Magnum/Math/Test/DualQuaternionTest.cpp +++ b/src/Magnum/Math/Test/DualQuaternionTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/DualQuaternion.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -275,6 +276,10 @@ void DualQuaternionTest::constructCopy() { DualQuaternion b(a); CORRADE_COMPARE(b, DualQuaternion({{1.0f, 2.0f, -3.0f}, -3.5f}, {{4.5f, -7.0f, 2.0f}, 1.0f})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/DualTest.cpp b/src/Magnum/Math/Test/DualTest.cpp index b289c6c6b..cec3c7d81 100644 --- a/src/Magnum/Math/Test/DualTest.cpp +++ b/src/Magnum/Math/Test/DualTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Dual.h" #include "Magnum/Math/Quaternion.h" @@ -184,6 +185,10 @@ void DualTest::constructCopy() { constexpr Dual b(a); CORRADE_COMPARE(b, Dual(2.0f, 3.0f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/FrustumTest.cpp b/src/Magnum/Math/Test/FrustumTest.cpp index e22e5ec7d..65618504c 100644 --- a/src/Magnum/Math/Test/FrustumTest.cpp +++ b/src/Magnum/Math/Test/FrustumTest.cpp @@ -29,6 +29,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Frustum.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -244,6 +245,10 @@ void FrustumTest::constructCopy() { constexpr Frustum b{a}; CORRADE_COMPARE(b, a); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/HalfTest.cpp b/src/Magnum/Math/Test/HalfTest.cpp index ce05e53ce..bf18ed16b 100644 --- a/src/Magnum/Math/Test/HalfTest.cpp +++ b/src/Magnum/Math/Test/HalfTest.cpp @@ -32,6 +32,7 @@ #if defined(DOXYGEN_GENERATING_OUTPUT) || defined(CORRADE_TARGET_UNIX) || (defined(CORRADE_TARGET_WINDOWS) && !defined(CORRADE_TARGET_WINDOWS_RT)) || defined(CORRADE_TARGET_EMSCRIPTEN) #include #endif +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Half.h" #include "Magnum/Math/Packing.h" @@ -562,6 +563,10 @@ void HalfTest::constructCopy() { CORRADE_COMPARE(b, Half{3.5f}); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/Matrix3Test.cpp b/src/Magnum/Math/Test/Matrix3Test.cpp index 46999c503..c4e7b193e 100644 --- a/src/Magnum/Math/Test/Matrix3Test.cpp +++ b/src/Magnum/Math/Test/Matrix3Test.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Matrix3.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -288,6 +289,10 @@ void Matrix3Test::constructCopy() { {4.5f, 4.0f, 7.0f}, {7.9f, -1.0f, 8.0f})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/Matrix4Test.cpp b/src/Magnum/Math/Test/Matrix4Test.cpp index 553ade30b..380b35a9d 100644 --- a/src/Magnum/Math/Test/Matrix4Test.cpp +++ b/src/Magnum/Math/Test/Matrix4Test.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Matrix4.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -336,6 +337,10 @@ void Matrix4Test::constructCopy() { {1.0f, 2.0f, 3.0f, -1.0f}, {7.9f, -1.0f, 8.0f, -1.5f})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/MatrixTest.cpp b/src/Magnum/Math/Test/MatrixTest.cpp index 40ad78569..f209e9339 100644 --- a/src/Magnum/Math/Test/MatrixTest.cpp +++ b/src/Magnum/Math/Test/MatrixTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Matrix.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -290,6 +291,10 @@ void MatrixTest::constructCopy() { CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif } void MatrixTest::convert() { diff --git a/src/Magnum/Math/Test/QuaternionTest.cpp b/src/Magnum/Math/Test/QuaternionTest.cpp index b31792c68..21ccd4ae8 100644 --- a/src/Magnum/Math/Test/QuaternionTest.cpp +++ b/src/Magnum/Math/Test/QuaternionTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Functions.h" #include "Magnum/Math/Matrix4.h" @@ -290,6 +291,10 @@ void QuaternionTest::constructCopy() { constexpr Quaternion b(a); CORRADE_COMPARE(b, Quaternion({1.0f, -3.0f, 7.0f}, 2.5f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/RangeTest.cpp b/src/Magnum/Math/Test/RangeTest.cpp index d2b81823f..0a712bd47 100644 --- a/src/Magnum/Math/Test/RangeTest.cpp +++ b/src/Magnum/Math/Test/RangeTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/FunctionsBatch.h" #include "Magnum/Math/Range.h" @@ -343,6 +344,14 @@ void RangeTest::constructCopy() { CORRADE_COMPARE(e, Range2Di({3, 5}, {23, 78})); CORRADE_COMPARE(f, Range3Di({3, 5, -7}, {23, 78, 2})); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index 63b4525c3..78f8402f9 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/RectangularMatrix.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -366,6 +367,10 @@ void RectangularMatrixTest::constructCopy() { Vector4(5.0f, 6.0f, 7.0f, 8.0f), Vector4(9.0f, 10.0f, 11.0f, 12.0f))); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/UnitTest.cpp b/src/Magnum/Math/Test/UnitTest.cpp index d61b5925c..f698db8d2 100644 --- a/src/Magnum/Math/Test/UnitTest.cpp +++ b/src/Magnum/Math/Test/UnitTest.cpp @@ -25,6 +25,7 @@ #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Constants.h" #include "Magnum/Math/Unit.h" @@ -38,6 +39,8 @@ struct UnitTest: Corrade::TestSuite::Tester { void constructDefault(); void constructNoInit(); void constructConversion(); + void constructCopy(); + void compare(); void compareNaN(); @@ -51,6 +54,8 @@ UnitTest::UnitTest() { &UnitTest::constructDefault, &UnitTest::constructNoInit, &UnitTest::constructConversion, + &UnitTest::constructCopy, + &UnitTest::compare, &UnitTest::compareNaN, @@ -119,6 +124,20 @@ void UnitTest::constructConversion() { CORRADE_VERIFY(std::is_nothrow_constructible::value); } +void UnitTest::constructCopy() { + constexpr Sec a{25.0f}; + + constexpr Sec b{a}; + CORRADE_COMPARE(b, a); + + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif + CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); + CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); +} + void UnitTest::compare() { CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()/2.0f) == Sec(25.0f)); CORRADE_VERIFY(Sec(25.0f + TypeTraits::epsilon()*75.0f) != Sec(25.0f)); diff --git a/src/Magnum/Math/Test/Vector2Test.cpp b/src/Magnum/Math/Test/Vector2Test.cpp index 1865e16a1..e5e442b84 100644 --- a/src/Magnum/Math/Test/Vector2Test.cpp +++ b/src/Magnum/Math/Test/Vector2Test.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Vector3.h" /* Vector3 used in Vector2Test::cross() */ #include "Magnum/Math/StrictWeakOrdering.h" @@ -168,6 +169,10 @@ void Vector2Test::constructCopy() { Vector2 b(a); CORRADE_COMPARE(b, Vector2(1.5f, 2.5f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/Vector3Test.cpp b/src/Magnum/Math/Test/Vector3Test.cpp index 51fd057b8..a1d7a58ba 100644 --- a/src/Magnum/Math/Test/Vector3Test.cpp +++ b/src/Magnum/Math/Test/Vector3Test.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Vector3.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -176,6 +177,10 @@ void Vector3Test::constructCopy() { Vector3 b(a); CORRADE_COMPARE(b, Vector3(1.0f, 2.5f, -3.0f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/Vector4Test.cpp b/src/Magnum/Math/Test/Vector4Test.cpp index 4fc6e503a..356a64750 100644 --- a/src/Magnum/Math/Test/Vector4Test.cpp +++ b/src/Magnum/Math/Test/Vector4Test.cpp @@ -26,6 +26,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Vector4.h" #include "Magnum/Math/StrictWeakOrdering.h" @@ -197,6 +198,10 @@ void Vector4Test::constructCopy() { Vector4 b(a); CORRADE_COMPARE(b, Vector4(1.0f, -2.5f, 3.0f, 4.1f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); } diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 509a6e34b..41b667ef3 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -27,6 +27,7 @@ #include #include #include +#include /* CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED */ #include "Magnum/Math/Half.h" #include "Magnum/Math/Vector.h" @@ -291,6 +292,10 @@ void VectorTest::constructCopy() { constexpr Vector4 b(a); CORRADE_COMPARE(b, Vector4(1.0f, 3.5f, 4.0f, -2.7f)); + #ifdef CORRADE_STD_IS_TRIVIALLY_TRAITS_SUPPORTED + CORRADE_VERIFY(std::is_trivially_copy_constructible::value); + CORRADE_VERIFY(std::is_trivially_copy_assignable::value); + #endif CORRADE_VERIFY(std::is_nothrow_copy_constructible::value); CORRADE_VERIFY(std::is_nothrow_copy_assignable::value); }