Browse Source

MSVC 2013 compatibility: more workarounds for array-initialization bug.

Follow-up to e2180ee85b.
Vladimír Vondruš 13 years ago
parent
commit
581ce482ea
  1. 7
      src/Array.h
  2. 42
      src/Math/BoolVector.h
  3. 4
      src/Math/Vector.h

7
src/Array.h

@ -69,7 +69,12 @@ template<UnsignedInt dimensions, class T> class Array {
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class ...U> constexpr /*implicit*/ Array(T first, U... next);
#else
template<class ...U, class V = typename std::enable_if<sizeof...(U)+1 == dimensions, T>::type> constexpr /*implicit*/ Array(T first, U... next): _data{first, next...} {}
template<class ...U, class V = typename std::enable_if<sizeof...(U)+1 == dimensions, T>::type> constexpr /*implicit*/ Array(T first, U... next):
#ifndef CORRADE_MSVC2013_COMPATIBILITY
_data{first, next...} {}
#else
_data({first, next...}) {}
#endif
#endif
/** @brief Construct array with one value for all fields */

42
src/Math/BoolVector.h

@ -33,6 +33,10 @@
#include "Types.h"
#ifdef CORRADE_MSVC2013_COMPATIBILITY
#include <array>
#endif
namespace Magnum { namespace Math {
namespace Implementation {
@ -79,7 +83,12 @@ template<std::size_t size> class BoolVector {
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class ...T> constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next);
#else
template<class ...T, class U = typename std::enable_if<sizeof...(T)+1 == DataSize, bool>::type> constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next): _data{first, UnsignedByte(next)...} {}
template<class ...T, class U = typename std::enable_if<sizeof...(T)+1 == DataSize, bool>::type> constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next):
#ifndef CORRADE_MSVC2013_COMPATIBILITY
_data{first, UnsignedByte(next)...} {}
#else
_data({first, UnsignedByte(next)...}) {}
#endif
#endif
/** @brief Construct boolean vector with one value for all fields */
@ -107,8 +116,22 @@ template<std::size_t size> class BoolVector {
*
* @see operator[](), set()
*/
UnsignedByte* data() { return _data; }
constexpr const UnsignedByte* data() const { return _data; } /**< @overload */
UnsignedByte* data() {
#ifndef CORRADE_MSVC2013_COMPATIBILITY
return _data;
#else
return _data.data();
#endif
}
/** @overload */
constexpr const UnsignedByte* data() const {
#ifndef CORRADE_MSVC2013_COMPATIBILITY
return _data;
#else
return _data.data();
#endif
}
/** @brief Bit at given position */
constexpr bool operator[](std::size_t i) const {
@ -211,9 +234,18 @@ template<std::size_t size> class BoolVector {
};
/* Implementation for Vector<size, T>::Vector(U) */
template<std::size_t ...sequence> constexpr explicit BoolVector(Implementation::Sequence<sequence...>, UnsignedByte value): _data{Implementation::repeat(value, sequence)...} {}
template<std::size_t ...sequence> constexpr explicit BoolVector(Implementation::Sequence<sequence...>, UnsignedByte value):
#ifndef CORRADE_MSVC2013_COMPATIBILITY
_data{Implementation::repeat(value, sequence)...} {}
#else
_data({Implementation::repeat(value, sequence)...}) {}
#endif
#ifndef CORRADE_MSVC2013_COMPATIBILITY
UnsignedByte _data[(size-1)/8+1];
#else
std::array<UnsignedByte, (size-1)/8+1> _data;
#endif
};
/** @debugoperator{Magnum::Math::BoolVector} */

4
src/Math/Vector.h

@ -40,10 +40,6 @@
#include "magnumVisibility.h"
#ifdef CORRADE_MSVC2013_COMPATIBILITY
#include <array>
#endif
namespace Magnum { namespace Math {
namespace Implementation {

Loading…
Cancel
Save