Browse Source

GCC 4.6 compatibility: no inheriting constructors in Math::Vector.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
deb54fc92f
  1. 8
      src/Math/Test/VectorTest.cpp
  2. 12
      src/Math/Vector.h

8
src/Math/Test/VectorTest.cpp

@ -154,13 +154,17 @@ void VectorTest::constExpressions() {
constexpr Vector4 b(1.0f, 3.5f, 4.0f, -2.7f);
CORRADE_COMPARE(b, Vector4(1.0f, 3.5f, 4.0f, -2.7f));
/* One-value constructor */
/* One-value constructor, not constexpr under GCC < 4.7 */
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4 c(7.0f);
CORRADE_COMPARE(c, Vector4(7.0f, 7.0f, 7.0f, 7.0f));
#endif
/* Conversion constructor */
/* Conversion constructor, not constexpr under GCC < 4.7 */
#ifndef CORRADE_GCC46_COMPATIBILITY
constexpr Vector4i d(b);
CORRADE_COMPARE(d, Vector4i(1, 3, 4, -2));
#endif
/* Copy constructor */
constexpr Vector4 e(b);

12
src/Math/Vector.h

@ -118,7 +118,13 @@ template<std::size_t size, class T> class Vector {
#ifdef DOXYGEN_GENERATING_OUTPUT
inline explicit Vector(T value);
#else
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type> inline constexpr explicit Vector(U value): Vector(typename Implementation::GenerateSequence<size>::Type(), value) {}
#else
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type> inline explicit Vector(U value) {
*this = Vector(typename Implementation::GenerateSequence<size>::Type(), value);
}
#endif
#endif
/**
@ -132,7 +138,13 @@ template<std::size_t size, class T> class Vector {
* // integral == {1, 2, -15, 7}
* @endcode
*/
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class U> inline constexpr explicit Vector(const Vector<size, U>& other): Vector(typename Implementation::GenerateSequence<size>::Type(), other) {}
#else
template<class U> inline explicit Vector(const Vector<size, U>& other) {
*this = Vector(typename Implementation::GenerateSequence<size>::Type(), other);
}
#endif
/** @brief Copy constructor */
inline constexpr Vector(const Vector<size, T>&) = default;

Loading…
Cancel
Save