From e69031b12c7aebc8c55fb187a71a168f35435133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 4 Jun 2013 20:46:38 +0200 Subject: [PATCH] GCC 4.4 compatibility: no std::declval here. --- src/Math/Matrix.h | 4 ++++ src/Math/Matrix3.h | 4 ++++ src/Math/Matrix4.h | 4 ++++ src/Math/RectangularMatrix.h | 14 ++++++++++++-- src/Math/Vector.h | 10 ++++++---- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index e5db427ea..158d23513 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -98,7 +98,11 @@ template class Matrix: public RectangularMatrix constexpr explicit Matrix(const RectangularMatrix& other): RectangularMatrix(other) {} /** @brief Construct matrix from external representation */ + #ifndef CORRADE_GCC44_COMPATIBILITY template::from(std::declval()))> constexpr explicit Matrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} + #else + template::from(*static_cast(nullptr)))> constexpr explicit Matrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} + #endif /** @brief Copy constructor */ constexpr Matrix(const RectangularMatrix& other): RectangularMatrix(other) {} diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index ac2bae462..cb6440926 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -143,7 +143,11 @@ template class Matrix3: public Matrix<3, T> { template constexpr explicit Matrix3(const RectangularMatrix<3, 3, U>& other): Matrix<3, T>(other) {} /** @brief Construct matrix from external representation */ + #ifndef CORRADE_GCC44_COMPATIBILITY template::from(std::declval()))> constexpr explicit Matrix3(const U& other): Matrix<3, T>(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(other)) {} + #else + template::from(*static_cast(nullptr)))> constexpr explicit Matrix3(const U& other): Matrix<3, T>(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(other)) {} + #endif /** @brief Copy constructor */ constexpr Matrix3(const RectangularMatrix<3, 3, T>& other): Matrix<3, T>(other) {} diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index bb3ed6c31..035ea65dd 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -206,7 +206,11 @@ template class Matrix4: public Matrix<4, T> { template constexpr explicit Matrix4(const RectangularMatrix<4, 4, U>& other): Matrix<4, T>(other) {} /** @brief Construct matrix from external representation */ + #ifndef CORRADE_GCC44_COMPATIBILITY template::from(std::declval()))> constexpr explicit Matrix4(const U& other): Matrix<4, T>(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(other)) {} + #else + template::from(*static_cast(nullptr)))> constexpr explicit Matrix4(const U& other): Matrix<4, T>(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(other)) {} + #endif /** @brief Copy constructor */ constexpr Matrix4(const RectangularMatrix<4, 4, T>& other): Matrix<4, T>(other) {} diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h index 6bc335b16..1a76f704d 100644 --- a/src/Math/RectangularMatrix.h +++ b/src/Math/RectangularMatrix.h @@ -146,7 +146,12 @@ template class RectangularMatrix { #ifndef CORRADE_GCC46_COMPATIBILITY template::from(std::declval()))> constexpr explicit RectangularMatrix(const U& other): RectangularMatrix(Implementation::RectangularMatrixConverter::from(other)) {} #else - template::from(std::declval()))> explicit RectangularMatrix(const U& other) { + #ifndef CORRADE_GCC44_COMPATIBILITY + template::from(std::declval()))> explicit RectangularMatrix(const U& other) + #else + template::from(*static_cast(nullptr)))> explicit RectangularMatrix(const U& other) + #endif + { *this = Implementation::RectangularMatrixConverter::from(other); } #endif @@ -158,7 +163,12 @@ template class RectangularMatrix { RectangularMatrix& operator=(const RectangularMatrix&) = default; /** @brief Convert matrix to external representation */ - template::to(std::declval>()))> constexpr explicit operator U() const { + #ifndef CORRADE_GCC44_COMPATIBILITY + template::to(std::declval>()))> constexpr explicit operator U() const + #else + template::to(*static_cast*>(nullptr)))> constexpr operator U() const + #endif + { /** @bug Why this is not constexpr under GCC 4.6? */ return Implementation::RectangularMatrixConverter::to(*this); } diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 086336a81..b03b5ccf5 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -162,10 +162,11 @@ template class Vector { template::from(std::declval()))> constexpr explicit Vector(const U& other): Vector(Implementation::VectorConverter::from(other)) {} #else #ifndef CORRADE_GCC44_COMPATIBILITY - template::from(std::declval()))> explicit Vector(const U& other) { + template::from(std::declval()))> explicit Vector(const U& other) #else - template::from(*static_cast(nullptr)))> explicit Vector(const U& other) { + template::from(*static_cast(nullptr)))> explicit Vector(const U& other) #endif + { *this = Implementation::VectorConverter::from(other); } #endif @@ -178,10 +179,11 @@ template class Vector { /** @brief Convert vector to external representation */ #ifndef CORRADE_GCC44_COMPATIBILITY - template::to(std::declval>()))> constexpr explicit operator U() const { + template::to(std::declval>()))> constexpr explicit operator U() const #else - template::to(*static_cast*>(nullptr)))> constexpr operator U() const { + template::to(*static_cast*>(nullptr)))> constexpr operator U() const #endif + { /** @bug Why this is not constexpr under GCC 4.6? */ return Implementation::VectorConverter::to(*this); }