Browse Source

MSVC 2015 Update 1: fixed nearly all constexpr bugs.

pull/132/head
Vladimír Vondruš 11 years ago
parent
commit
6e8c16c960
  1. 6
      src/Magnum/Array.h
  2. 19
      src/Magnum/ImageView.h
  3. 7
      src/Magnum/Math/BoolVector.h
  4. 7
      src/Magnum/Math/Complex.h
  5. 7
      src/Magnum/Math/DualComplex.h
  6. 7
      src/Magnum/Math/DualQuaternion.h
  7. 9
      src/Magnum/Math/Matrix.h
  8. 20
      src/Magnum/Math/Matrix3.h
  9. 22
      src/Magnum/Math/Matrix4.h
  10. 7
      src/Magnum/Math/Quaternion.h
  11. 7
      src/Magnum/Math/Range.h
  12. 26
      src/Magnum/Math/RectangularMatrix.h
  13. 12
      src/Magnum/Math/Test/BoolVectorTest.cpp
  14. 11
      src/Magnum/Math/Test/ComplexTest.cpp
  15. 11
      src/Magnum/Math/Test/DualComplexTest.cpp
  16. 11
      src/Magnum/Math/Test/DualQuaternionTest.cpp
  17. 29
      src/Magnum/Math/Test/MatrixTest.cpp
  18. 11
      src/Magnum/Math/Test/QuaternionTest.cpp
  19. 29
      src/Magnum/Math/Test/RangeTest.cpp
  20. 29
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  21. 5
      src/Magnum/Math/Test/Vector2Test.cpp
  22. 5
      src/Magnum/Math/Test/Vector3Test.cpp
  23. 5
      src/Magnum/Math/Test/Vector4Test.cpp
  24. 23
      src/Magnum/Math/Test/VectorTest.cpp
  25. 28
      src/Magnum/Math/Vector.h
  26. 18
      src/Magnum/Math/Vector2.h
  27. 18
      src/Magnum/Math/Vector3.h
  28. 18
      src/Magnum/Math/Vector4.h
  29. 6
      src/Magnum/Test/ArrayTest.cpp

6
src/Magnum/Array.h

@ -77,11 +77,7 @@ template<UnsignedInt dimensions, class T> class Array {
constexpr /*implicit*/ Array(T value);
#else
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && dimensions != 1, T>::type>
#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
/*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence<dimensions>::Type(), value) {}
constexpr /*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence<dimensions>::Type(), value) {}
#endif
/** @brief Equality */

19
src/Magnum/ImageView.h

@ -108,11 +108,7 @@ template<UnsignedInt dimensions> class ImageView {
/** @overload
* Similar to the above, but uses default @ref PixelStorage parameters.
*/
#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 ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size) noexcept: ImageView{{}, format, type, size} {}
constexpr explicit ImageView(PixelFormat format, PixelType type, const VectorTypeFor<dimensions, Int>& size) noexcept: ImageView{{}, format, type, size} {}
/** @brief Storage of pixel data */
PixelStorage storage() const { return _storage; }
@ -241,11 +237,7 @@ template<UnsignedInt dimensions> class CompressedImageView {
* Similar the above, but uses default @ref CompressedPixelStorage
* parameters (or the hardcoded ones in OpenGL ES and WebGL).
*/
#if !defined(CORRADE_MSVC2015_COMPATIBILITY) || defined(MAGNUM_TARGET_GLES)
/* 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 CompressedImageView(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data) noexcept;
constexpr explicit CompressedImageView(CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, Containers::ArrayView<const void> data) noexcept;
#ifndef MAGNUM_TARGET_GLES
/**
@ -364,12 +356,7 @@ template<UnsignedInt dimensions> constexpr CompressedImageView<dimensions>::Comp
_format{format}, _size{size} {}
#ifndef MAGNUM_TARGET_GLES
template<UnsignedInt dimensions>
#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
CompressedImageView<dimensions>::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<const void> data) noexcept: CompressedImageView{{}, format, size, data} {}
template<UnsignedInt dimensions> constexpr CompressedImageView<dimensions>::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size, const Containers::ArrayView<const void> data) noexcept: CompressedImageView{{}, format, size, data} {}
template<UnsignedInt dimensions> constexpr CompressedImageView<dimensions>::CompressedImageView(const CompressedPixelFormat format, const VectorTypeFor<dimensions, Int>& size) noexcept: CompressedImageView{{}, format, size} {}
#endif

7
src/Magnum/Math/BoolVector.h

@ -93,12 +93,7 @@ template<std::size_t size> class BoolVector {
#ifdef DOXYGEN_GENERATING_OUTPUT
inline explicit BoolVector(T value);
#else
template<class T, class U = typename std::enable_if<std::is_same<bool, T>::value && size != 1, bool>::type>
#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 BoolVector(T value): BoolVector(typename Implementation::GenerateSequence<DataSize>::Type(), value ? FullSegmentMask : 0) {}
template<class T, class U = typename std::enable_if<std::is_same<bool, T>::value && size != 1, bool>::type> constexpr explicit BoolVector(T value): BoolVector(typename Implementation::GenerateSequence<DataSize>::Type(), value ? FullSegmentMask : 0) {}
#endif
/** @brief Copy constructor */

7
src/Magnum/Math/Complex.h

@ -178,12 +178,7 @@ template<class T> class Complex {
template<class U> constexpr explicit Complex(const Complex<U>& other): _real{T(other._real)}, _imaginary{T(other._imaginary)} {}
/** @brief Construct complex number from external representation */
template<class U, class V = decltype(Implementation::ComplexConverter<T, U>::from(std::declval<U>()))>
#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 Complex(const U& other): Complex{Implementation::ComplexConverter<T, U>::from(other)} {}
template<class U, class V = decltype(Implementation::ComplexConverter<T, U>::from(std::declval<U>()))> constexpr explicit Complex(const U& other): Complex{Implementation::ComplexConverter<T, U>::from(other)} {}
/** @brief Convert complex number to external representation */
template<class U, class V = decltype(Implementation::ComplexConverter<T, U>::to(std::declval<Complex<T>>()))> constexpr explicit operator U() const {

7
src/Magnum/Math/DualComplex.h

@ -163,12 +163,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
{}
/** @brief Construct dual complex number from external representation */
template<class U, class V = decltype(Implementation::DualComplexConverter<T, U>::from(std::declval<U>()))>
#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 DualComplex(const U& other): DualComplex{Implementation::DualComplexConverter<T, U>::from(other)} {}
template<class U, class V = decltype(Implementation::DualComplexConverter<T, U>::from(std::declval<U>()))> constexpr explicit DualComplex(const U& other): DualComplex{Implementation::DualComplexConverter<T, U>::from(other)} {}
/** @brief Copy constructor */
constexpr DualComplex(const Dual<Complex<T>>& other): Dual<Complex<T>>(other) {}

7
src/Magnum/Math/DualQuaternion.h

@ -234,12 +234,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
template<class U> constexpr explicit DualQuaternion(const DualQuaternion<U>& other): Dual<Quaternion<T>>(other) {}
/** @brief Construct dual quaternion from external representation */
template<class U, class V = decltype(Implementation::DualQuaternionConverter<T, U>::from(std::declval<U>()))>
#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 DualQuaternion(const U& other): DualQuaternion{Implementation::DualQuaternionConverter<T, U>::from(other)} {}
template<class U, class V = decltype(Implementation::DualQuaternionConverter<T, U>::from(std::declval<U>()))> constexpr explicit DualQuaternion(const U& other): DualQuaternion{Implementation::DualQuaternionConverter<T, U>::from(other)} {}
/** @brief Copy constructor */
constexpr DualQuaternion(const Dual<Quaternion<T>>& other): Dual<Quaternion<T>>(other) {}

9
src/Magnum/Math/Matrix.h

@ -132,14 +132,7 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
* // integral == {{1, 2}, {-15, 7}}
* @endcode
*/
template<class U> constexpr explicit Matrix(const RectangularMatrix<size, size, U>& other):
#ifndef CORRADE_MSVC2015_COMPATIBILITY
RectangularMatrix<size, size, T>(other)
#else
/* Avoid using non-constexpr version */
RectangularMatrix<size, size, T>(typename Implementation::GenerateSequence<size>::Type(), other)
#endif
{}
template<class U> constexpr explicit Matrix(const RectangularMatrix<size, size, U>& other): RectangularMatrix<size, size, T>(other) {}
/** @brief Construct matrix from external representation */
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<size, size, T, U>::from(std::declval<U>()))> constexpr explicit Matrix(const U& other): RectangularMatrix<size, size, T>(Implementation::RectangularMatrixConverter<size, size, T, U>::from(other)) {}

20
src/Magnum/Math/Matrix3.h

@ -162,15 +162,8 @@ template<class T> class Matrix3: public Matrix3x3<T> {
constexpr /*implicit*/ Matrix3(IdentityInitT = IdentityInit, T value = T{1})
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_MSVC2015_COMPATIBILITY
: Matrix3x3<T>{IdentityInit, value}
#else
/* Avoid using non-constexpr version, also MSVC 2015 can't handle
{} here */
: Matrix3x3<T>(Vector<3, T>{value, T(0), T(0)},
Vector<3, T>{T(0), value, T(0)},
Vector<3, T>{T(0), T(0), value})
#endif
/* MSVC 2015 can't handle {} here */
: Matrix3x3<T>(IdentityInit, value)
#endif
{}
@ -178,15 +171,8 @@ template<class T> class Matrix3: public Matrix3x3<T> {
constexpr explicit Matrix3(ZeroInitT)
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_MSVC2015_COMPATIBILITY
/* MSVC 2015 can't handle {} here */
: Matrix3x3<T>(ZeroInit)
#else
/* Avoid using non-constexpr version, also MSVC 2015 can't handle
{} here */
: Matrix3x3<T>(Vector<3, T>{T(0), T(0), T(0)},
Vector<3, T>{T(0), T(0), T(0)},
Vector<3, T>{T(0), T(0), T(0)})
#endif
#endif
{}

22
src/Magnum/Math/Matrix4.h

@ -258,16 +258,8 @@ template<class T> class Matrix4: public Matrix4x4<T> {
constexpr /*implicit*/ Matrix4(IdentityInitT = IdentityInit, T value = T{1})
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_MSVC2015_COMPATIBILITY
: Matrix4x4<T>{IdentityInit, value}
#else
/* Avoid using non-constexpr version, also MSVC 2015 can't handle
{} here */
: Matrix4x4<T>(Vector<4, T>{value, T(0), T(0), T(0)},
Vector<4, T>{T(0), value, T(0), T(0)},
Vector<4, T>{T(0), T(0), value, T(0)},
Vector<4, T>{T(0), T(0), T(0), value})
#endif
/* MSVC 2015 can't handle {} here */
: Matrix4x4<T>(IdentityInit, value)
#endif
{}
@ -275,16 +267,8 @@ template<class T> class Matrix4: public Matrix4x4<T> {
constexpr explicit Matrix4(ZeroInitT)
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
#ifndef CORRADE_MSVC2015_COMPATIBILITY
/* MSVC 2015 can't handle {} here */
: Matrix4x4<T>(ZeroInit)
#else
/* Avoid using non-constexpr version, also MSVC 2015 can't handle
{} here */
: Matrix4x4<T>(Vector<4, T>{T(0), T(0), T(0), T(0)},
Vector<4, T>{T(0), T(0), T(0), T(0)},
Vector<4, T>{T(0), T(0), T(0), T(0)},
Vector<4, T>{T(0), T(0), T(0), T(0)})
#endif
#endif
{}

7
src/Magnum/Math/Quaternion.h

@ -241,12 +241,7 @@ template<class T> class Quaternion {
template<class U> constexpr explicit Quaternion(const Quaternion<U>& other): _vector{other._vector}, _scalar{T(other._scalar)} {}
/** @brief Construct quaternion from external representation */
template<class U, class V = decltype(Implementation::QuaternionConverter<T, U>::from(std::declval<U>()))>
#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 Quaternion(const U& other): Quaternion{Implementation::QuaternionConverter<T, U>::from(other)} {}
template<class U, class V = decltype(Implementation::QuaternionConverter<T, U>::from(std::declval<U>()))> constexpr explicit Quaternion(const U& other): Quaternion{Implementation::QuaternionConverter<T, U>::from(other)} {}
/** @brief Convert quaternion to external representation */
template<class U, class V = decltype(Implementation::QuaternionConverter<T, U>::to(std::declval<Quaternion<T>>()))> constexpr explicit operator U() const {

7
src/Magnum/Math/Range.h

@ -99,12 +99,7 @@ template<UnsignedInt dimensions, class T> class Range {
template<class U> constexpr explicit Range(const Range<dimensions, U>& other): _min(other._min), _max(other._max) {}
/** @brief Construct range from external representation */
template<class U, class V = decltype(Implementation::RangeConverter<dimensions, T, U>::from(std::declval<U>()))>
#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 Range(const U& other): Range{Implementation::RangeConverter<dimensions, T, U>::from(other)} {}
template<class U, class V = decltype(Implementation::RangeConverter<dimensions, T, U>::from(std::declval<U>()))> constexpr explicit Range(const U& other): Range{Implementation::RangeConverter<dimensions, T, U>::from(other)} {}
/** @brief Convert range to external representation */
template<class U, class V = decltype(Implementation::RangeConverter<dimensions, T, U>::to(std::declval<Range<dimensions, T>>()))> constexpr explicit operator U() const {

26
src/Magnum/Math/RectangularMatrix.h

@ -57,11 +57,6 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
template<std::size_t, std::size_t, class> friend class RectangularMatrix;
#ifdef CORRADE_MSVC2015_COMPATIBILITY
/* Delegating constexpr constructor workarounds */
friend class Matrix<cols, T>;
#endif
public:
typedef T Type; /**< @brief Underlying data type */
@ -113,12 +108,7 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
}
/** @brief Construct zero-filled matrix */
/** @todo Remove MSVC workaround when fixed */
#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
/*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit)
constexpr /*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit)
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
/* MSVC 2015 can't handle {} here */
@ -157,20 +147,10 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
* // integral == {1, 2, -15, 7}
* @endcode
*/
template<class U>
#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<cols, rows, U>& other): RectangularMatrix(typename Implementation::GenerateSequence<cols>::Type(), other) {}
template<class U> constexpr explicit RectangularMatrix(const RectangularMatrix<cols, rows, U>& other): RectangularMatrix(typename Implementation::GenerateSequence<cols>::Type(), other) {}
/** @brief Construct matrix from external representation */
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(std::declval<U>()))>
#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 U& other): RectangularMatrix(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(other)) {}
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(std::declval<U>()))> constexpr explicit RectangularMatrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(other)) {}
/** @brief Copy constructor */
constexpr RectangularMatrix(const RectangularMatrix<cols, rows, T>&) = default;

12
src/Magnum/Math/Test/BoolVectorTest.cpp

@ -99,18 +99,10 @@ void BoolVectorTest::constructNoInit() {
}
void BoolVectorTest::constructOneValue() {
#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
BoolVector19 a(false);
constexpr BoolVector19 a(false);
CORRADE_COMPARE(a, BoolVector19(0x00, 0x00, 0x00));
#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
BoolVector19 b(true);
constexpr BoolVector19 b(true);
CORRADE_COMPARE(b, BoolVector19(0xff, 0xff, 0x07));
CORRADE_VERIFY(!(std::is_convertible<bool, BoolVector19>::value));

11
src/Magnum/Math/Test/ComplexTest.cpp

@ -201,19 +201,14 @@ void ComplexTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Complex c(a);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Cmpl d(b);
constexpr Cmpl d(b);
CORRADE_COMPARE(d.re, a.re);
CORRADE_COMPARE(d.im, a.im);

11
src/Magnum/Math/Test/DualComplexTest.cpp

@ -198,19 +198,14 @@ void DualComplexTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
DualComplex c{a};
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
DualCmpl d(b);
constexpr DualCmpl d(b);
CORRADE_COMPARE(d.re, a.re);
CORRADE_COMPARE(d.im, a.im);
CORRADE_COMPARE(d.x, a.x);

11
src/Magnum/Math/Test/DualQuaternionTest.cpp

@ -216,19 +216,14 @@ void DualQuaternionTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
DualQuaternion c{a};
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
DualQuat d(b);
constexpr DualQuat d(b);
CORRADE_COMPARE(d.re.x, a.re.x);
CORRADE_COMPARE(d.re.y, a.re.y);
CORRADE_COMPARE(d.re.z, a.re.z);

29
src/Magnum/Math/Test/MatrixTest.cpp

@ -126,21 +126,9 @@ void MatrixTest::construct() {
}
void MatrixTest::constructIdentity() {
#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
Matrix4x4 identity;
#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
Matrix4x4 identity2{IdentityInit};
#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
Matrix4x4 identity3{IdentityInit, 4.0f};
constexpr Matrix4x4 identity;
constexpr Matrix4x4 identity2{IdentityInit};
constexpr Matrix4x4 identity3{IdentityInit, 4.0f};
Matrix4x4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f),
Vector4(0.0f, 1.0f, 0.0f, 0.0f),
@ -158,11 +146,7 @@ void MatrixTest::constructIdentity() {
}
void MatrixTest::constructZero() {
#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
Matrix4x4 a{ZeroInit};
constexpr Matrix4x4 a{ZeroInit};
CORRADE_COMPARE(a, Matrix4x4(Vector4(0.0f, 0.0f, 0.0f, 0.0f),
Vector4(0.0f, 0.0f, 0.0f, 0.0f),
Vector4(0.0f, 0.0f, 0.0f, 0.0f),
@ -222,10 +206,7 @@ void MatrixTest::convert() {
constexpr Matrix3x3 c(b);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Mat3 d(b);
constexpr Mat3 d(b);
for(std::size_t i = 0; i != 9; ++i)
CORRADE_COMPARE(d.a[i], a.a[i]);

11
src/Magnum/Math/Test/QuaternionTest.cpp

@ -202,19 +202,14 @@ void QuaternionTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Quaternion c{a};
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Quat d(b);
constexpr Quat d(b);
CORRADE_COMPARE(d.x, a.x);
CORRADE_COMPARE(d.y, a.y);
CORRADE_COMPARE(d.z, a.z);

29
src/Magnum/Math/Test/RangeTest.cpp

@ -215,11 +215,7 @@ 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});
#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);
constexpr Range1Di d(a);
CORRADE_COMPARE(d, Range1Di(1, -15));
constexpr Range2Di e(b);
@ -260,14 +256,12 @@ void RangeTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Range<2, Float> g{b};
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Range1D h{a};
@ -284,26 +278,17 @@ void RangeTest::convert() {
CORRADE_COMPARE(i, e);
CORRADE_COMPARE(j, f);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Dim k(d);
constexpr Dim k(d);
CORRADE_COMPARE(k.offset, a.offset);
CORRADE_COMPARE(k.size, a.size);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Rect l(e);
constexpr Rect l(e);
CORRADE_COMPARE(l.x, b.x);
CORRADE_COMPARE(l.y, b.y);
CORRADE_COMPARE(l.w, b.w);
CORRADE_COMPARE(l.h, b.h);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Box m(f);
constexpr Box m(f);
CORRADE_COMPARE(m.x, c.x);
CORRADE_COMPARE(m.y, c.y);
CORRADE_COMPARE(m.z, c.z);

29
src/Magnum/Math/Test/RectangularMatrixTest.cpp

@ -149,16 +149,8 @@ void RectangularMatrixTest::construct() {
}
void RectangularMatrixTest::constructDefault() {
#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
Matrix4x3 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
Matrix4x3 b{ZeroInit};
constexpr Matrix4x3 a;
constexpr Matrix4x3 b{ZeroInit};
CORRADE_COMPARE(a, Matrix4x3(Vector3(0.0f, 0.0f, 0.0f),
Vector3(0.0f, 0.0f, 0.0f),
Vector3(0.0f, 0.0f, 0.0f),
@ -182,11 +174,7 @@ void RectangularMatrixTest::constructNoInit() {
void RectangularMatrixTest::constructConversion() {
constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f),
Vector2(-15.0f, 7.0f));
#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);
constexpr Matrix2x2i b(a);
CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2),
Vector2i(-15, 7)));
@ -245,19 +233,14 @@ void RectangularMatrixTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Matrix2x3 c{a};
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Mat2x3 d(b);
constexpr Mat2x3 d(b);
for(std::size_t i = 0; i != 5; ++i)
CORRADE_COMPARE(d.a[i], a.a[i]);

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

@ -152,10 +152,7 @@ void Vector2Test::convert() {
constexpr Vector2 c(a);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Vec2 d(b);
constexpr Vec2 d(b);
CORRADE_COMPARE(d.x, a.x);
CORRADE_COMPARE(d.y, a.y);

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

@ -156,10 +156,7 @@ void Vector3Test::convert() {
constexpr Vector3 c(a);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Vec3 d(b);
constexpr Vec3 d(b);
CORRADE_COMPARE(d.x, a.x);
CORRADE_COMPARE(d.y, a.y);
CORRADE_COMPARE(d.z, a.z);

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

@ -171,10 +171,7 @@ void Vector4Test::convert() {
constexpr Vector4 c(a);
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Vec4 d(b);
constexpr Vec4 d(b);
CORRADE_COMPARE(d.x, a.x);
CORRADE_COMPARE(d.y, a.y);
CORRADE_COMPARE(d.z, a.z);

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

@ -201,11 +201,7 @@ void VectorTest::constructNoInit() {
}
void VectorTest::constructOneValue() {
#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
Vector4 a(7.25f);
constexpr Vector4 a(7.25f);
CORRADE_COMPARE(a, Vector4(7.25f, 7.25f, 7.25f, 7.25f));
@ -223,11 +219,7 @@ void VectorTest::constructOneComponent() {
void VectorTest::constructConversion() {
constexpr Vector4 a(1.3f, 2.7f, -15.0f, 7.0f);
#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);
constexpr Vector4i b(a);
CORRADE_COMPARE(b, Vector4i(1, 2, -15, 7));
@ -247,19 +239,14 @@ void VectorTest::convert() {
/* GCC 5.1 fills the result with zeros instead of properly calling
delegated copy constructor if using constexpr. Reported here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450
MSVC 2015: Can't use delegating constructors with constexpr:
https://connect.microsoft.com/VisualStudio/feedback/details/1579279/c-constexpr-does-not-work-with-delegating-constructors */
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66450 */
#if !defined(__GNUC__) || defined(__clang__)
constexpr
#endif
Vector3 c{a};
CORRADE_COMPARE(c, b);
#ifndef CORRADE_MSVC2015_COMPATIBILITY /* Why can't be conversion constexpr? */
constexpr
#endif
Vec3 d(b);
constexpr Vec3 d(b);
CORRADE_COMPARE(d.x, a.x);
CORRADE_COMPARE(d.y, a.y);
CORRADE_COMPARE(d.z, a.z);

28
src/Magnum/Math/Vector.h

@ -98,13 +98,6 @@ template<std::size_t size, class T> class Vector {
template<std::size_t, class> friend class Vector;
#ifdef CORRADE_MSVC2015_COMPATIBILITY
/* Delegating constexpr constructor workarounds */
friend class Vector2<T>;
friend class Vector3<T>;
friend class Vector4<T>;
#endif
public:
typedef T Type; /**< @brief Underlying data type */
@ -188,12 +181,7 @@ template<std::size_t size, class T> class Vector {
#ifdef DOXYGEN_GENERATING_OUTPUT
constexpr explicit Vector(T value);
#else
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type>
#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 Vector(U value): Vector(typename Implementation::GenerateSequence<size>::Type(), value) {}
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type> constexpr explicit Vector(U value): Vector(typename Implementation::GenerateSequence<size>::Type(), value) {}
#endif
/**
@ -207,20 +195,10 @@ template<std::size_t size, class T> class Vector {
* // integral == {1, 2, -15, 7}
* @endcode
*/
template<class U>
#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 Vector(const Vector<size, U>& other): Vector(typename Implementation::GenerateSequence<size>::Type(), other) {}
template<class U> constexpr explicit Vector(const Vector<size, U>& other): Vector(typename Implementation::GenerateSequence<size>::Type(), other) {}
/** @brief Construct vector from external representation */
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(std::declval<U>()))>
#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 Vector(const U& other): Vector(Implementation::VectorConverter<size, T, U>::from(other)) {}
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(std::declval<U>()))> constexpr explicit Vector(const U& other): Vector(Implementation::VectorConverter<size, T, U>::from(other)) {}
/** @brief Copy constructor */
constexpr Vector(const Vector<size, T>&) = default;

18
src/Magnum/Math/Vector2.h

@ -130,14 +130,7 @@ template<class T> class Vector2: public Vector<2, T> {
{}
/** @copydoc Vector::Vector(T) */
constexpr explicit Vector2(T value):
#ifndef CORRADE_MSVC2015_COMPATIBILITY
Vector<2, T>(value)
#else
/* Avoid using non-constexpr version */
Vector<2, T>(value, value)
#endif
{}
constexpr explicit Vector2(T value): Vector<2, T>(value) {}
/**
* @brief Constructor
@ -149,14 +142,7 @@ template<class T> class Vector2: public Vector<2, T> {
constexpr /*implicit*/ Vector2(T x, T y): Vector<2, T>(x, y) {}
/** @copydoc Vector::Vector(const Vector<size, U>&) */
template<class U> 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
{}
template<class U> constexpr explicit Vector2(const Vector<2, U>& other): Vector<2, T>(other) {}
/** @brief Construct vector from external representation */
template<class U, class V =

18
src/Magnum/Math/Vector3.h

@ -152,14 +152,7 @@ template<class T> class Vector3: public Vector<3, T> {
{}
/** @copydoc Vector::Vector(T) */
constexpr explicit Vector3(T value):
#ifndef CORRADE_MSVC2015_COMPATIBILITY
Vector<3, T>(value)
#else
/* Avoid using non-constexpr version */
Vector<3, T>(value, value, value)
#endif
{}
constexpr explicit Vector3(T value): Vector<3, T>(value) {}
/**
* @brief Constructor
@ -180,14 +173,7 @@ template<class T> class Vector3: public Vector<3, T> {
constexpr /*implicit*/ Vector3(const Vector2<T>& xy, T z): Vector<3, T>(xy[0], xy[1], z) {}
/** @copydoc Vector::Vector(const Vector<size, U>&) */
template<class U> 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
{}
template<class U> constexpr explicit Vector3(const Vector<3, U>& other): Vector<3, T>(other) {}
/** @brief Construct vector from external representation */
template<class U, class V =

18
src/Magnum/Math/Vector4.h

@ -78,14 +78,7 @@ template<class T> class Vector4: public Vector<4, T> {
{}
/** @copydoc Vector::Vector(T) */
constexpr explicit Vector4(T value):
#ifndef CORRADE_MSVC2015_COMPATIBILITY
Vector<4, T>(value)
#else
/* Avoid using non-constexpr version */
Vector<4, T>(value, value, value, value)
#endif
{}
constexpr explicit Vector4(T value): Vector<4, T>(value) {}
/**
* @brief Constructor
@ -106,14 +99,7 @@ template<class T> class Vector4: public Vector<4, T> {
constexpr /*implicit*/ Vector4(const Vector3<T>& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {}
/** @copydoc Vector::Vector(const Vector<size, U>&) */
template<class U> 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
{}
template<class U> constexpr explicit Vector4(const Vector<4, U>& other): Vector<4, T>(other) {}
/** @brief Construct vector from external representation */
template<class U, class V = decltype(Implementation::VectorConverter<4, T, U>::from(std::declval<U>()))> constexpr explicit Vector4(const U& other): Vector<4, T>(Implementation::VectorConverter<4, T, U>::from(other)) {}

6
src/Magnum/Test/ArrayTest.cpp

@ -51,11 +51,7 @@ void ArrayTest::construct() {
constexpr Array<3, Int> a = {5, 6, 7};
CORRADE_COMPARE(a, (Array<3, Int>(5, 6, 7)));
#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
Array<3, Int> a2 = 5;
constexpr Array<3, Int> a2 = 5;
CORRADE_COMPARE(a2, (Array<3, Int>(5, 5, 5)));
constexpr Array1D b = 5;

Loading…
Cancel
Save