Browse Source

GCC 4.4 compatibility: no std::declval here.

Vladimír Vondruš 13 years ago
parent
commit
125e01f62e
  1. 8
      src/Math/Vector.h
  2. 4
      src/Math/Vector2.h
  3. 4
      src/Math/Vector3.h
  4. 4
      src/Math/Vector4.h

8
src/Math/Vector.h

@ -165,7 +165,11 @@ template<std::size_t size, class T> class Vector {
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(std::declval<U>()))> inline 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>()))> inline explicit Vector(const U& other) {
#else
template<class U, class V = decltype(Implementation::VectorConverter<size, T, U>::from(*static_cast<const U*>(nullptr)))> inline explicit Vector(const U& other) {
#endif
*this = Implementation::VectorConverter<size, T, U>::from(other);
}
#endif
@ -177,7 +181,11 @@ template<std::size_t size, class T> class Vector {
inline Vector<size, T>& operator=(const Vector<size, T>&) = default;
/** @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>>()))> inline 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)))> inline constexpr operator U() const {
#endif
/** @bug Why this is not constexpr under GCC 4.6? */
return Implementation::VectorConverter<size, T, U>::to(*this);
}

4
src/Math/Vector2.h

@ -99,7 +99,11 @@ template<class T> class Vector2: public Vector<2, T> {
template<class U> inline constexpr explicit Vector2(const Vector<2, U>& other): Vector<2, T>(other) {}
/** @brief Construct vector from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<2, T, U>::from(std::declval<U>()))> inline constexpr explicit Vector2(const U& other): Vector<2, T>(Implementation::VectorConverter<2, T, U>::from(other)) {}
#else
template<class U, class V = decltype(Implementation::VectorConverter<2, T, U>::from(*static_cast<const U*>(nullptr)))> inline constexpr explicit Vector2(const U& other): Vector<2, T>(Implementation::VectorConverter<2, T, U>::from(other)) {}
#endif
/** @brief Copy constructor */
inline constexpr Vector2(const Vector<2, T>& other): Vector<2, T>(other) {}

4
src/Math/Vector3.h

@ -140,7 +140,11 @@ template<class T> class Vector3: public Vector<3, T> {
template<class U> inline constexpr explicit Vector3(const Vector<3, U>& other): Vector<3, T>(other) {}
/** @brief Construct vector from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<3, T, U>::from(std::declval<U>()))> inline constexpr explicit Vector3(const U& other): Vector<3, T>(Implementation::VectorConverter<3, T, U>::from(other)) {}
#else
template<class U, class V = decltype(Implementation::VectorConverter<3, T, U>::from(*static_cast<const U*>(nullptr)))> inline constexpr explicit Vector3(const U& other): Vector<3, T>(Implementation::VectorConverter<3, T, U>::from(other)) {}
#endif
/** @brief Copy constructor */
inline constexpr Vector3(const Vector<3, T>& other): Vector<3, T>(other) {}

4
src/Math/Vector4.h

@ -70,7 +70,11 @@ template<class T> class Vector4: public Vector<4, T> {
template<class U> inline constexpr explicit Vector4(const Vector<4, U>& other): Vector<4, T>(other) {}
/** @brief Construct vector from external representation */
#ifndef CORRADE_GCC44_COMPATIBILITY
template<class U, class V = decltype(Implementation::VectorConverter<4, T, U>::from(std::declval<U>()))> inline constexpr explicit Vector4(const U& other): Vector<4, T>(Implementation::VectorConverter<4, T, U>::from(other)) {}
#else
template<class U, class V = decltype(Implementation::VectorConverter<4, T, U>::from(*static_cast<const U*>(nullptr)))> inline constexpr explicit Vector4(const U& other): Vector<4, T>(Implementation::VectorConverter<4, T, U>::from(other)) {}
#endif
/** @brief Copy constructor */
inline constexpr Vector4(const Vector<4, T>& other): Vector<4, T>(other) {}

Loading…
Cancel
Save