Browse Source

GCC 4.4 compatibility: no std::declval here.

Vladimír Vondruš 13 years ago
parent
commit
e69031b12c
  1. 4
      src/Math/Matrix.h
  2. 4
      src/Math/Matrix3.h
  3. 4
      src/Math/Matrix4.h
  4. 14
      src/Math/RectangularMatrix.h
  5. 10
      src/Math/Vector.h

4
src/Math/Matrix.h

@ -98,7 +98,11 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
template<class U> constexpr explicit Matrix(const RectangularMatrix<size, size, U>& other): RectangularMatrix<size, size, T>(other) {}
/** @brief Construct matrix from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
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)) {}
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<size, size, T, U>::from(*static_cast<const U*>(nullptr)))> constexpr explicit Matrix(const U& other): RectangularMatrix<size, size, T>(Implementation::RectangularMatrixConverter<size, size, T, U>::from(other)) {}
#endif
/** @brief Copy constructor */
constexpr Matrix(const RectangularMatrix<size, size, T>& other): RectangularMatrix<size, size, T>(other) {}

4
src/Math/Matrix3.h

@ -143,7 +143,11 @@ template<class T> class Matrix3: public Matrix<3, T> {
template<class U> constexpr explicit Matrix3(const RectangularMatrix<3, 3, U>& other): Matrix<3, T>(other) {}
/** @brief Construct matrix from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(std::declval<U>()))> constexpr explicit Matrix3(const U& other): Matrix<3, T>(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(other)) {}
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<3, 3, T, U>::from(*static_cast<const U*>(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) {}

4
src/Math/Matrix4.h

@ -206,7 +206,11 @@ template<class T> class Matrix4: public Matrix<4, T> {
template<class U> constexpr explicit Matrix4(const RectangularMatrix<4, 4, U>& other): Matrix<4, T>(other) {}
/** @brief Construct matrix from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(std::declval<U>()))> constexpr explicit Matrix4(const U& other): Matrix<4, T>(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(other)) {}
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<4, 4, T, U>::from(*static_cast<const U*>(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) {}

14
src/Math/RectangularMatrix.h

@ -146,7 +146,12 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
#ifndef CORRADE_GCC46_COMPATIBILITY
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)) {}
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(std::declval<U>()))> explicit RectangularMatrix(const U& other) {
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(std::declval<U>()))> explicit RectangularMatrix(const U& other)
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(*static_cast<const U*>(nullptr)))> explicit RectangularMatrix(const U& other)
#endif
{
*this = Implementation::RectangularMatrixConverter<cols, rows, T, U>::from(other);
}
#endif
@ -158,7 +163,12 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
RectangularMatrix<cols, rows, T>& operator=(const RectangularMatrix<cols, rows, T>&) = default;
/** @brief Convert matrix to external representation */
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::to(std::declval<RectangularMatrix<cols, rows, T>>()))> constexpr explicit operator U() const {
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::to(std::declval<RectangularMatrix<cols, rows, T>>()))> constexpr explicit operator U() const
#else
template<class U, class V = decltype(Implementation::RectangularMatrixConverter<cols, rows, T, U>::to(*static_cast<const RectangularMatrix<cols, rows, T>*>(nullptr)))> constexpr operator U() const
#endif
{
/** @bug Why this is not constexpr under GCC 4.6? */
return Implementation::RectangularMatrixConverter<cols, rows, T, U>::to(*this);
}

10
src/Math/Vector.h

@ -162,10 +162,11 @@ template<std::size_t size, class T> class Vector {
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)) {}
#else
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(std::declval<U>()))> explicit Vector(const U& other) {
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(std::declval<U>()))> explicit Vector(const U& other)
#else
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(*static_cast<const U*>(nullptr)))> explicit Vector(const U& other) {
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(*static_cast<const U*>(nullptr)))> explicit Vector(const U& other)
#endif
{
*this = Implementation::VectorConverter<size, T, U>::from(other);
}
#endif
@ -178,10 +179,11 @@ template<std::size_t size, class T> class Vector {
/** @brief Convert vector to external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::to(std::declval<Vector<size, T>>()))> constexpr explicit operator U() const {
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::to(std::declval<Vector<size, T>>()))> constexpr explicit operator U() const
#else
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::to(*static_cast<const Vector<size, T>*>(nullptr)))> constexpr operator U() const {
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::to(*static_cast<const Vector<size, T>*>(nullptr)))> constexpr operator U() const
#endif
{
/** @bug Why this is not constexpr under GCC 4.6? */
return Implementation::VectorConverter<size, T, U>::to(*this);
}

Loading…
Cancel
Save