Browse Source

MSVC 2015 compatibility: Math external conversion constexpr issues.

Caused by inability to delegate constexpr constructors. Subclasses are
okay, fortunately.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
000d8f8129
  1. 7
      src/Magnum/Math/Complex.h
  2. 7
      src/Magnum/Math/DualComplex.h
  3. 7
      src/Magnum/Math/DualQuaternion.h
  4. 7
      src/Magnum/Math/Quaternion.h
  5. 7
      src/Magnum/Math/Range.h
  6. 7
      src/Magnum/Math/RectangularMatrix.h
  7. 6
      src/Magnum/Math/Test/ComplexTest.cpp
  8. 6
      src/Magnum/Math/Test/DualComplexTest.cpp
  9. 6
      src/Magnum/Math/Test/DualQuaternionTest.cpp
  10. 6
      src/Magnum/Math/Test/QuaternionTest.cpp
  11. 8
      src/Magnum/Math/Test/RangeTest.cpp
  12. 6
      src/Magnum/Math/Test/RectangularMatrixTest.cpp
  13. 6
      src/Magnum/Math/Test/VectorTest.cpp
  14. 7
      src/Magnum/Math/Vector.h

7
src/Magnum/Math/Complex.h

@ -168,7 +168,12 @@ template<class T> class Complex {
constexpr explicit Complex(const Vector2<T>& vector): _real(vector.x()), _imaginary(vector.y()) {}
/** @brief Construct complex number from external representation */
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)} {}
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)} {}
/** @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

@ -150,7 +150,12 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
#endif
/** @brief Construct dual complex number from external representation */
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)} {}
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)} {}
/** @brief Copy constructor */
constexpr DualComplex(const Dual<Complex<T>>& other): Dual<Complex<T>>(other) {}

7
src/Magnum/Math/DualQuaternion.h

@ -158,7 +158,12 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
#endif
/** @brief Construct dual quaternion from external representation */
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)} {}
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)} {}
/** @brief Copy constructor */
constexpr DualQuaternion(const Dual<Quaternion<T>>& other): Dual<Quaternion<T>>(other) {}

7
src/Magnum/Math/Quaternion.h

@ -225,7 +225,12 @@ template<class T> class Quaternion {
constexpr explicit Quaternion(const Vector3<T>& vector): _vector(vector), _scalar(T(0)) {}
/** @brief Construct quaternion from external representation */
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)} {}
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)} {}
/** @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,7 +99,12 @@ 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>()))> constexpr 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>()))>
#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)} {}
/** @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 {

7
src/Magnum/Math/RectangularMatrix.h

@ -165,7 +165,12 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
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>()))> constexpr 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>()))>
#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)) {}
/** @brief Copy constructor */
constexpr RectangularMatrix(const RectangularMatrix<cols, rows, T>&) = default;

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

@ -187,8 +187,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
Complex c(a);

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

@ -181,8 +181,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
DualComplex c{a};

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

@ -182,8 +182,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
DualQuaternion c{a};

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

@ -188,8 +188,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
Quaternion c{a};

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

@ -260,12 +260,14 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
Range<2, Float> g{b};
#if !defined(__GNUC__) || defined(__clang__)
#if (!defined(__GNUC__) || defined(__clang__)) && !defined(CORRADE_MSVC2015_COMPATIBILITY)
constexpr
#endif
Range1D h{a};

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

@ -237,8 +237,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
Matrix2x3 c{a};

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

@ -247,8 +247,10 @@ 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 */
#if !defined(__GNUC__) || defined(__clang__)
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)
constexpr
#endif
Vector3 c{a};

7
src/Magnum/Math/Vector.h

@ -211,7 +211,12 @@ template<std::size_t size, class T> class Vector {
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>()))> constexpr 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>()))>
#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)) {}
/** @brief Copy constructor */
constexpr Vector(const Vector<size, T>&) = default;

Loading…
Cancel
Save