diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index 09e9c9442..161ad0100 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -132,7 +132,14 @@ template class Matrix: public RectangularMatrix constexpr explicit Matrix(const RectangularMatrix& other): RectangularMatrix(other) {} + template constexpr explicit Matrix(const RectangularMatrix& other): + #ifndef CORRADE_MSVC2015_COMPATIBILITY + RectangularMatrix(other) + #else + /* Avoid using non-constexpr version */ + RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) + #endif + {} /** @brief Construct matrix from external representation */ template::from(std::declval()))> constexpr explicit Matrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} diff --git a/src/Magnum/Math/RectangularMatrix.h b/src/Magnum/Math/RectangularMatrix.h index 94a096634..ac875a179 100644 --- a/src/Magnum/Math/RectangularMatrix.h +++ b/src/Magnum/Math/RectangularMatrix.h @@ -57,6 +57,11 @@ template class RectangularMatrix { template friend class RectangularMatrix; + #ifdef CORRADE_MSVC2015_COMPATIBILITY + /* Delegating constexpr constructor workarounds */ + friend class Matrix; + #endif + public: typedef T Type; /**< @brief Underlying data type */ @@ -152,7 +157,12 @@ template class RectangularMatrix { * // integral == {1, 2, -15, 7} * @endcode */ - template constexpr explicit RectangularMatrix(const RectangularMatrix& other): RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) {} + template + #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ + constexpr + #endif + explicit RectangularMatrix(const RectangularMatrix& other): RectangularMatrix(typename Implementation::GenerateSequence::Type(), other) {} /** @brief Construct matrix from external representation */ template::from(std::declval()))> constexpr explicit RectangularMatrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} diff --git a/src/Magnum/Math/Test/RangeTest.cpp b/src/Magnum/Math/Test/RangeTest.cpp index 5fcd2c5b3..fe310842e 100644 --- a/src/Magnum/Math/Test/RangeTest.cpp +++ b/src/Magnum/Math/Test/RangeTest.cpp @@ -215,7 +215,11 @@ void RangeTest::constructConversion() { constexpr Range2D b({1.3f, 2.7f}, {-15.0f, 7.0f}); constexpr Range3D c({1.3f, 2.7f, -1.5f}, {-15.0f, 7.0f, 0.3f}); - constexpr Range1Di d(a); + #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ + constexpr + #endif + Range1Di d(a); CORRADE_COMPARE(d, Range1Di(1, -15)); constexpr Range2Di e(b); diff --git a/src/Magnum/Math/Test/RectangularMatrixTest.cpp b/src/Magnum/Math/Test/RectangularMatrixTest.cpp index 6424915c5..dccd1bc5b 100644 --- a/src/Magnum/Math/Test/RectangularMatrixTest.cpp +++ b/src/Magnum/Math/Test/RectangularMatrixTest.cpp @@ -174,7 +174,11 @@ void RectangularMatrixTest::constructNoInit() { void RectangularMatrixTest::constructConversion() { constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f), Vector2(-15.0f, 7.0f)); - constexpr Matrix2x2i b(a); + #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ + constexpr + #endif + Matrix2x2i b(a); CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2), Vector2i(-15, 7))); diff --git a/src/Magnum/Math/Test/VectorTest.cpp b/src/Magnum/Math/Test/VectorTest.cpp index 165640e55..fab671094 100644 --- a/src/Magnum/Math/Test/VectorTest.cpp +++ b/src/Magnum/Math/Test/VectorTest.cpp @@ -223,7 +223,11 @@ void VectorTest::constructOneComponent() { void VectorTest::constructConversion() { constexpr Vector4 a(1.3f, 2.7f, -15.0f, 7.0f); - constexpr Vector4i b(a); + #ifndef CORRADE_MSVC2015_COMPATIBILITY + /* Can't use delegating constructors with constexpr -- https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */ + constexpr + #endif + Vector4i b(a); CORRADE_COMPARE(b, Vector4i(1, 2, -15, 7)); diff --git a/src/Magnum/Math/Vector.h b/src/Magnum/Math/Vector.h index 8018d8862..83d53df76 100644 --- a/src/Magnum/Math/Vector.h +++ b/src/Magnum/Math/Vector.h @@ -94,6 +94,13 @@ template class Vector { template friend class Vector; + #ifdef CORRADE_MSVC2015_COMPATIBILITY + /* Delegating constexpr constructor workarounds */ + friend class Vector2; + friend class Vector3; + friend class Vector4; + #endif + public: typedef T Type; /**< @brief Underlying data type */ diff --git a/src/Magnum/Math/Vector2.h b/src/Magnum/Math/Vector2.h index 4c0302cb2..c32129762 100644 --- a/src/Magnum/Math/Vector2.h +++ b/src/Magnum/Math/Vector2.h @@ -149,7 +149,14 @@ template class Vector2: public Vector<2, T> { constexpr /*implicit*/ Vector2(T x, T y): Vector<2, T>(x, y) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector2(const Vector<2, U>& other): Vector<2, T>(other) {} + template constexpr explicit Vector2(const Vector<2, U>& other): + #ifndef CORRADE_MSVC2015_COMPATIBILITY + Vector<2, T>(other) + #else + /* Avoid using non-constexpr version */ + Vector<2, T>(typename Implementation::GenerateSequence<2>::Type(), other) + #endif + {} /** @brief Construct vector from external representation */ template::from(std::declval()))> constexpr explicit Vector2(const U& other): Vector<2, T>(Implementation::VectorConverter<2, T, U>::from(other)) {} diff --git a/src/Magnum/Math/Vector3.h b/src/Magnum/Math/Vector3.h index 9fb54127f..57299eaea 100644 --- a/src/Magnum/Math/Vector3.h +++ b/src/Magnum/Math/Vector3.h @@ -180,7 +180,14 @@ template class Vector3: public Vector<3, T> { constexpr /*implicit*/ Vector3(const Vector2& xy, T z): Vector<3, T>(xy[0], xy[1], z) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector3(const Vector<3, U>& other): Vector<3, T>(other) {} + template constexpr explicit Vector3(const Vector<3, U>& other): + #ifndef CORRADE_MSVC2015_COMPATIBILITY + Vector<3, T>(other) + #else + /* Avoid using non-constexpr version */ + Vector<3, T>(typename Implementation::GenerateSequence<3>::Type(), other) + #endif + {} /** @brief Construct vector from external representation */ template::from(std::declval()))> constexpr explicit Vector3(const U& other): Vector<3, T>(Implementation::VectorConverter<3, T, U>::from(other)) {} diff --git a/src/Magnum/Math/Vector4.h b/src/Magnum/Math/Vector4.h index d4d099587..6d465df68 100644 --- a/src/Magnum/Math/Vector4.h +++ b/src/Magnum/Math/Vector4.h @@ -106,7 +106,14 @@ template class Vector4: public Vector<4, T> { constexpr /*implicit*/ Vector4(const Vector3& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {} /** @copydoc Vector::Vector(const Vector&) */ - template constexpr explicit Vector4(const Vector<4, U>& other): Vector<4, T>(other) {} + template constexpr explicit Vector4(const Vector<4, U>& other): + #ifndef CORRADE_MSVC2015_COMPATIBILITY + Vector<4, T>(other) + #else + /* Avoid using non-constexpr version */ + Vector<4, T>(typename Implementation::GenerateSequence<4>::Type(), other) + #endif + {} /** @brief Construct vector from external representation */ template::from(std::declval()))> constexpr explicit Vector4(const U& other): Vector<4, T>(Implementation::VectorConverter<4, T, U>::from(other)) {}