Browse Source

Math: MSVC 2015 strikes again!

Fortunately on Vector itself the new constexpr operations seem to work,
if not on subclasses.
pull/168/head
Vladimír Vondruš 2 years ago
parent
commit
22f17108d5
  1. 20
      src/Magnum/Math/Test/ColorTest.cpp
  2. 10
      src/Magnum/Math/Test/Vector2Test.cpp
  3. 10
      src/Magnum/Math/Test/Vector3Test.cpp
  4. 10
      src/Magnum/Math/Test/Vector4Test.cpp
  5. 115
      src/Magnum/Math/Test/VectorTest.cpp

20
src/Magnum/Math/Test/ColorTest.cpp

@ -1091,12 +1091,24 @@ void ColorTest::multiplyDivideIntegral() {
constexpr Color3i cvector3{32, 10, -6};
constexpr Color4i cvector4{32, 10, -6, 2};
constexpr Color3i ca31 = cvector3*-1.5f;
constexpr Color4i ca41 = cvector4*-1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Color3i ca31 = cvector3*-1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Color4i ca41 = cvector4*-1.5f;
/* On MSVC 2015 this picks an int*Vector2i overload, leading to a wrong
result, unless MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION() is used */
constexpr Color3i ca32 = -1.5f*cvector3;
constexpr Color4i ca42 = -1.5f*cvector4;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Color3i ca32 = -1.5f*cvector3;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Color4i ca42 = -1.5f*cvector4;
CORRADE_COMPARE(ca31, multiplied3);
CORRADE_COMPARE(ca41, multiplied4);
CORRADE_COMPARE(ca32, multiplied3);

10
src/Magnum/Math/Test/Vector2Test.cpp

@ -263,10 +263,16 @@ void Vector2Test::multiplyDivideIntegral() {
CORRADE_COMPARE(-1.5f*vector, multiplied);
constexpr Vector2i cvector{32, -6};
constexpr Vector2i ca1 = cvector*-1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector2i ca1 = cvector*-1.5f;
/* On MSVC 2015 this picks an int*Vector2i overload, leading to a wrong
result, unless MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION() is used */
constexpr Vector2i ca2 = -1.5f*cvector;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector2i ca2 = -1.5f*cvector;
CORRADE_COMPARE(ca1, multiplied);
CORRADE_COMPARE(ca2, multiplied);
}

10
src/Magnum/Math/Test/Vector3Test.cpp

@ -287,10 +287,16 @@ void Vector3Test::multiplyDivideIntegral() {
CORRADE_COMPARE(-1.5f*vector, multiplied);
constexpr Vector3i cvector{32, 10, -6};
constexpr Vector3i ca1 = cvector*-1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector3i ca1 = cvector*-1.5f;
/* On MSVC 2015 this picks an int*Vector2i overload, leading to a wrong
result, unless MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION() is used */
constexpr Vector3i ca2 = -1.5f*cvector;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector3i ca2 = -1.5f*cvector;
CORRADE_COMPARE(ca1, multiplied);
CORRADE_COMPARE(ca2, multiplied);
}

10
src/Magnum/Math/Test/Vector4Test.cpp

@ -301,10 +301,16 @@ void Vector4Test::multiplyDivideIntegral() {
CORRADE_COMPARE(-1.5f*vector, multiplied);
constexpr Vector4i cvector{32, 10, -6, 2};
constexpr Vector4i ca1 = cvector*-1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector4i ca1 = cvector*-1.5f;
/* On MSVC 2015 this picks an int*Vector2i overload, leading to a wrong
result, unless MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION() is used */
constexpr Vector4i ca2 = -1.5f*cvector;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vector4i ca2 = -1.5f*cvector;
CORRADE_COMPARE(ca1, multiplied);
CORRADE_COMPARE(ca2, multiplied);
}

115
src/Magnum/Math/Test/VectorTest.cpp

@ -935,7 +935,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(-Vec2(-2.0f, 5.0f), Vec2(2.0f, -5.0f));
{
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb = -ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cb = -ca;
CORRADE_COMPARE(cb, (Vec2{2.0f, -5.0f}));
}
@ -948,7 +951,10 @@ void VectorTest::subclass() {
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb{1.0f, -3.0f};
constexpr Vec2 cc = ca + cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cc = ca + cb;
CORRADE_COMPARE(cc, (Vec2{-1.0f, 2.0f}));
}
@ -960,7 +966,10 @@ void VectorTest::subclass() {
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb{1.0f, -3.0f};
constexpr Vec2 cc = ca - cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cc = ca - cb;
CORRADE_COMPARE(cc, (Vec2{-3.0f, 8.0f}));
}
@ -973,8 +982,14 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2{-4.0f, 10.0f}));
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb1 = ca*2.0f;
constexpr Vec2 cb2 = 2.0f*ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cb1 = ca*2.0f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cb2 = 2.0f*ca;
CORRADE_COMPARE(cb1, (Vec2{-4.0f, 10.0f}));
CORRADE_COMPARE(cb2, (Vec2{-4.0f, 10.0f}));
}
@ -987,8 +1002,14 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2{-4.0f, 10.0f}));
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb1 = ca/0.5f;
constexpr Vec2 cb2 = 2.0f/ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cb1 = ca/0.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cb2 = 2.0f/ca;
CORRADE_COMPARE(cb1, (Vec2{-4.0f, 10.0f}));
CORRADE_COMPARE(cb2, (Vec2{-1.0f, 0.4f}));
}
@ -1002,8 +1023,14 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2i{3, 6}));
constexpr Vec2i ca{2, 4};
constexpr Vec2i cb1 = ca*1.5f;
constexpr Vec2i cb2 = 1.5f*ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb1 = ca*1.5f;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb2 = 1.5f*ca;
CORRADE_COMPARE(cb1, (Vec2i{3, 6}));
CORRADE_COMPARE(cb2, (Vec2i{3, 6}));
}
@ -1020,7 +1047,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2i{3, 6}));
constexpr Vec2i ca{2, 4};
constexpr Vec2i cb = ca/(2.0f/3.0f);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb = ca/(2.0f/3.0f);
CORRADE_COMPARE(cb, (Vec2i{3, 6}));
}
@ -1033,7 +1063,10 @@ void VectorTest::subclass() {
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb{1.5f, -2.0f};
constexpr Vec2 cc = ca*cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cc = ca*cb;
CORRADE_COMPARE(cc, (Vec2{-3.0f, -10.0f}));
}
@ -1045,7 +1078,10 @@ void VectorTest::subclass() {
constexpr Vec2 ca{-2.0f, 5.0f};
constexpr Vec2 cb{2.0f/3.0f, -0.5f};
constexpr Vec2 cc = ca/cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2 cc = ca/cb;
CORRADE_COMPARE(cc, (Vec2{-3.0f, -10.0f}));
}
@ -1059,8 +1095,14 @@ void VectorTest::subclass() {
constexpr Vec2i ca{2, 4};
constexpr Vec2 cb{-1.5f, 0.5f};
constexpr Vec2i cc1 = ca*cb;
constexpr Vec2i cc2 = cb*ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc1 = ca*cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc2 = cb*ca;
CORRADE_COMPARE(cc1, (Vec2i{-3, 2}));
CORRADE_COMPARE(cc2, (Vec2i{-3, 2}));
}
@ -1078,7 +1120,10 @@ void VectorTest::subclass() {
constexpr Vec2i ca{2, 4};
constexpr Vec2 cb{-2.0f/3.0f, 2.0f};
constexpr Vec2i cc = ca/cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc = ca/cb;
CORRADE_COMPARE(cc, (Vec2i{-3, 2}));
}
@ -1090,7 +1135,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2i{0, 1}));
constexpr Vec2i ca{4, 13};
constexpr Vec2i cb = ca % 2;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb = ca % 2;
CORRADE_COMPARE(cb, (Vec2i{0, 1}));
}
@ -1102,7 +1150,10 @@ void VectorTest::subclass() {
constexpr Vec2i ca{4, 13};
constexpr Vec2i cb{2, 5};
constexpr Vec2i cc = ca % cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc = ca % cb;
CORRADE_COMPARE(cc, (Vec2i{0, 3}));
}
@ -1110,7 +1161,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(~Vec2i(85, 240), Vec2i(-86, -241));
{
constexpr Vec2i ca{85, 240};
constexpr Vec2i cb = ~ca;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb = ~ca;
CORRADE_COMPARE(cb, (Vec2i{-86, -241}));
}
@ -1123,7 +1177,10 @@ void VectorTest::subclass() {
constexpr Vec2i ca{85, 240};
constexpr Vec2i cb{170, 85};
constexpr Vec2i cc = ca & cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc = ca & cb;
CORRADE_COMPARE(cc, (Vec2i{0, 80}));
}
@ -1135,7 +1192,10 @@ void VectorTest::subclass() {
constexpr Vec2i ca{85, 240};
constexpr Vec2i cb{170, 85};
constexpr Vec2i cc = ca | cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc = ca | cb;
CORRADE_COMPARE(cc, (Vec2i{255, 245}));
}
@ -1147,7 +1207,10 @@ void VectorTest::subclass() {
constexpr Vec2i ca{85, 240};
constexpr Vec2i cb{170, 85};
constexpr Vec2i cc = ca ^ cb;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cc = ca ^ cb;
CORRADE_COMPARE(cc, (Vec2i{255, 165}));
}
@ -1159,7 +1222,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2i{28, 128}));
constexpr Vec2i ca{7, 32};
constexpr Vec2i cb = ca << 2;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb = ca << 2;
CORRADE_COMPARE(cb, (Vec2i{28, 128}));
}
@ -1170,7 +1236,10 @@ void VectorTest::subclass() {
CORRADE_COMPARE(a, (Vec2i{1, 8}));
constexpr Vec2i ca{7, 32};
constexpr Vec2i cb = ca >> 2;
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* No idea? */
constexpr
#endif
Vec2i cb = ca >> 2;
CORRADE_COMPARE(cb, (Vec2i{1, 8}));
}

Loading…
Cancel
Save