Browse Source

MSVC 2015 compatibility: issue with constexpr and delegating constructors.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
7f6c7b09d8
  1. 7
      src/Magnum/Array.h
  2. 7
      src/Magnum/Math/RectangularMatrix.h
  3. 14
      src/Magnum/Math/Vector.h

7
src/Magnum/Array.h

@ -76,7 +76,12 @@ template<UnsignedInt dimensions, class T> class Array {
#ifdef DOXYGEN_GENERATING_OUTPUT
constexpr /*implicit*/ Array(T value);
#else
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && dimensions != 1, T>::type> constexpr /*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence<dimensions>::Type(), value) {}
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && dimensions != 1, T>::type>
#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
/*implicit*/ Array(U value): Array(typename Math::Implementation::GenerateSequence<dimensions>::Type(), value) {}
#endif
/** @brief Equality */

7
src/Magnum/Math/RectangularMatrix.h

@ -108,7 +108,12 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
}
/** @brief Construct zero-filled matrix */
constexpr /*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit)
/** @todo Remove MSVC workaround when fixed */
#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
/*implicit*/ RectangularMatrix(ZeroInitT = ZeroInit)
/** @todoc remove workaround when doxygen is sane */
#ifndef DOXYGEN_GENERATING_OUTPUT
/* MSVC 2015 can't handle {} here */

14
src/Magnum/Math/Vector.h

@ -174,7 +174,12 @@ template<std::size_t size, class T> class Vector {
#ifdef DOXYGEN_GENERATING_OUTPUT
constexpr explicit Vector(T value);
#else
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type> constexpr explicit Vector(U value): Vector(typename Implementation::GenerateSequence<size>::Type(), value) {}
template<class U, class V = typename std::enable_if<std::is_same<T, U>::value && size != 1, T>::type>
#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(U value): Vector(typename Implementation::GenerateSequence<size>::Type(), value) {}
#endif
/**
@ -188,7 +193,12 @@ template<std::size_t size, class T> class Vector {
* // integral == {1, 2, -15, 7}
* @endcode
*/
template<class U> constexpr explicit Vector(const Vector<size, U>& other): Vector(typename Implementation::GenerateSequence<size>::Type(), other) {}
template<class 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 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)) {}

Loading…
Cancel
Save