diff --git a/src/AbstractImage.cpp b/src/AbstractImage.cpp index 4194431c2..de0e9929c 100644 --- a/src/AbstractImage.cpp +++ b/src/AbstractImage.cpp @@ -16,6 +16,8 @@ #include "AbstractImage.h" #include "TypeTraits.h" +using namespace std; + namespace Magnum { size_t AbstractImage::pixelSize(Components format, ComponentType type) { diff --git a/src/AbstractImage.h b/src/AbstractImage.h index f32b17e03..e310ff00a 100644 --- a/src/AbstractImage.h +++ b/src/AbstractImage.h @@ -268,7 +268,7 @@ class MAGNUM_EXPORT AbstractImage { * @param components Color components * @param type Data type */ - static size_t pixelSize(Components components, ComponentType type); + static std::size_t pixelSize(Components components, ComponentType type); /** * @brief Constructor diff --git a/src/Buffer.h b/src/Buffer.h index 5a35d152b..a7ff8df08 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -250,7 +250,7 @@ class Buffer { * setData(GLsizeiptr, const GLvoid*, Usage). * @see setData(Target, GLsizeiptr, const GLvoid*, Usage) */ - template inline void setData(const T(&data)[size], Usage usage) { + template inline void setData(const T(&data)[size], Usage usage) { setData(_defaultTarget, data, usage); } @@ -291,7 +291,7 @@ class Buffer { * * @see setData(Target, GLsizeiptr, const GLvoid*, Usage) */ - template inline void setData(Target target, const T(&data)[size], Usage usage) { + template inline void setData(Target target, const T(&data)[size], Usage usage) { setData(target, size*sizeof(T), data, usage); } @@ -330,7 +330,7 @@ class Buffer { * setSubData(GLintptr, GLsizeiptr, const GLvoid*). * @see setSubData(Target, GLintptr, GLsizeiptr, const GLvoid*) */ - template inline void setSubData(GLintptr offset, const T(&data)[size]) { + template inline void setSubData(GLintptr offset, const T(&data)[size]) { setSubData(_defaultTarget, offset, data); } @@ -370,7 +370,7 @@ class Buffer { * setSubData(Target, GLintptr, GLsizeiptr, const GLvoid*). * @see setSubData(Target, GLintptr, GLsizeiptr, const GLvoid*) */ - template inline void setSubData(Target target, GLintptr offset, const T(&data)[size]) { + template inline void setSubData(Target target, GLintptr offset, const T(&data)[size]) { setSubData(target, offset, size*sizeof(T), data); } diff --git a/src/Context.h b/src/Context.h index f603889b1..820b998e5 100644 --- a/src/Context.h +++ b/src/Context.h @@ -76,12 +76,12 @@ class MAGNUM_EXPORT Extension { private: /* GCC 4.6 doesn't like const members, as std::vector doesn't have proper move semantic yet */ - size_t _index; + std::size_t _index; Version _requiredVersion; Version _coreVersion; const char* _string; - inline constexpr Extension(size_t index, Version requiredVersion, Version coreVersion, const char* string): _index(index), _requiredVersion(requiredVersion), _coreVersion(coreVersion), _string(string) {} + inline constexpr Extension(std::size_t index, Version requiredVersion, Version coreVersion, const char* string): _index(index), _requiredVersion(requiredVersion), _coreVersion(coreVersion), _string(string) {} }; /** diff --git a/src/DimensionTraits.h b/src/DimensionTraits.h index d5c3a15aa..fe188f2b3 100644 --- a/src/DimensionTraits.h +++ b/src/DimensionTraits.h @@ -24,7 +24,7 @@ namespace Magnum { namespace Math { - template class Vector; + template class Vector; template class Vector2; template class Vector3; diff --git a/src/Extensions.h b/src/Extensions.h index 44385b8be..8fd0cadf5 100644 --- a/src/Extensions.h +++ b/src/Extensions.h @@ -38,7 +38,7 @@ namespace Extensions { #ifndef DOXYGEN_GENERATING_OUTPUT #define _extension(prefix, vendor, extension, _requiredVersion, _coreVersion) \ struct extension { \ - enum: size_t { Index = __LINE__-1 }; \ + enum: std::size_t { Index = __LINE__-1 }; \ constexpr static Version requiredVersion() { return Version::_requiredVersion; } \ constexpr static Version coreVersion() { return Version::_coreVersion; } \ constexpr static const char* string() { return #prefix "_" #vendor "_" #extension; } \ diff --git a/src/Math/Algorithms/GaussJordan.h b/src/Math/Algorithms/GaussJordan.h index a3e9fafb4..2778fa5c2 100644 --- a/src/Math/Algorithms/GaussJordan.h +++ b/src/Math/Algorithms/GaussJordan.h @@ -48,7 +48,7 @@ class GaussJordan { * and the final backsubstitution is done only on @p t, as @p a would * always end with identity matrix anyway. */ - template static bool inPlaceTransposed(RectangularMatrix& a, RectangularMatrix& t); + template static bool inPlaceTransposed(RectangularMatrix& a, RectangularMatrix& t); /** * @brief Eliminate in place @@ -56,7 +56,7 @@ class GaussJordan { * Transposes the matrices, calls inPlaceTransposed() on them and then * transposes them back. */ - template static bool inPlace(RectangularMatrix& a, RectangularMatrix& t) { + template static bool inPlace(RectangularMatrix& a, RectangularMatrix& t) { a = a.transposed(); RectangularMatrix tTransposed = t.transposed(); @@ -69,11 +69,11 @@ class GaussJordan { } }; -template bool GaussJordan::inPlaceTransposed(RectangularMatrix& a, RectangularMatrix& t) { - for(size_t row = 0; row != size; ++row) { +template bool GaussJordan::inPlaceTransposed(RectangularMatrix& a, RectangularMatrix& t) { + for(std::size_t row = 0; row != size; ++row) { /* Find max pivot */ - size_t rowMax = row; - for(size_t row2 = row+1; row2 != size; ++row2) + std::size_t rowMax = row; + for(std::size_t row2 = row+1; row2 != size; ++row2) if(std::abs(a(row2, row)) > std::abs(a(rowMax, row))) rowMax = row2; @@ -86,7 +86,7 @@ template bool GaussJordan::inPlaceTransposed( return false; /* Eliminate column */ - for(size_t row2 = row+1; row2 != size; ++row2) { + for(std::size_t row2 = row+1; row2 != size; ++row2) { T c = a(row2, row)/a(row, row); a[row2] -= a[row]*c; @@ -95,10 +95,10 @@ template bool GaussJordan::inPlaceTransposed( } /* Backsubstitute */ - for(size_t row = size; row != 0; --row) { + for(std::size_t row = size; row != 0; --row) { T c = T(1)/a(row-1, row-1); - for(size_t row2 = 0; row2 != row-1; ++row2) + for(std::size_t row2 = 0; row2 != row-1; ++row2) t[row2] -= t[row-1]*a(row2, row-1)*c; /* Normalize the row */ diff --git a/src/Math/MathTypeTraits.h b/src/Math/MathTypeTraits.h index efe47f3a6..adf408955 100644 --- a/src/Math/MathTypeTraits.h +++ b/src/Math/MathTypeTraits.h @@ -112,7 +112,7 @@ template struct MathTypeTraitsFloatingPoint { } }; -template struct MathTypeTraitsLong {}; +template struct MathTypeTraitsLong {}; template<> struct MathTypeTraitsLong { typedef unsigned int UnsignedType; diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 07d21527b..2f882cc2f 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -25,7 +25,7 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { - template class MatrixDeterminant; + template class MatrixDeterminant; } #endif @@ -38,9 +38,9 @@ See @ref matrix-vector for brief introduction. @configurationvalueref{Magnum::Math::Matrix} */ -template class Matrix: public RectangularMatrix { +template class Matrix: public RectangularMatrix { public: - const static size_t Size = size; /**< @brief %Matrix size */ + const static std::size_t Size = size; /**< @brief %Matrix size */ /** @brief Pass to constructor to create zero-filled matrix */ enum ZeroType { Zero }; @@ -63,7 +63,7 @@ template class Matrix: public RectangularMatrix class Matrix: public RectangularMatrix ij(size_t skipCol, size_t skipRow) const { + Matrix ij(std::size_t skipCol, std::size_t skipRow) const { Matrix out(Matrix::Zero); - for(size_t col = 0; col != size-1; ++col) - for(size_t row = 0; row != size-1; ++row) + for(std::size_t col = 0; col != size-1; ++col) + for(std::size_t row = 0; row != size-1; ++row) out(col, row) = (*this)(col + (col >= skipCol), row + (row >= skipRow)); @@ -135,8 +135,8 @@ template class Matrix: public RectangularMatrix class Matrix: public RectangularMatrix operator*(const Matrix& other) const { return RectangularMatrix::operator*(other); } - template inline RectangularMatrix operator*(const RectangularMatrix& other) const { + template inline RectangularMatrix operator*(const RectangularMatrix& other) const { return RectangularMatrix::operator*(other); } inline Vector operator*(const Vector& other) const { @@ -159,16 +159,16 @@ template class Matrix: public RectangularMatrix inline typename std::enable_if::value, Matrix>::type operator*(U number, const Matrix& matrix) { +template inline typename std::enable_if::value, Matrix>::type operator*(U number, const Matrix& matrix) { return number*RectangularMatrix(matrix); } -template inline typename std::enable_if::value, Matrix>::type operator/(U number, const Matrix& matrix) { +template inline typename std::enable_if::value, Matrix>::type operator/(U number, const Matrix& matrix) { return number/RectangularMatrix(matrix); } #endif /** @debugoperator{Magnum::Math::Matrix} */ -template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Matrix& value) { +template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Matrix& value) { return debug << static_cast&>(value); } @@ -189,10 +189,10 @@ template inline Corrade::Utility::Debug operator<<(Corrade return *this; \ } \ \ - inline VectorType& operator[](size_t col) { \ + inline VectorType& operator[](std::size_t col) { \ return VectorType::from(Matrix::data()+col*size); \ } \ - inline constexpr const VectorType& operator[](size_t col) const { \ + inline constexpr const VectorType& operator[](std::size_t col) const { \ return VectorType::from(Matrix::data()+col*size); \ } \ \ @@ -203,7 +203,7 @@ template inline Corrade::Utility::Debug operator<<(Corrade Matrix::operator*=(other); \ return *this; \ } \ - template inline RectangularMatrix operator*(const RectangularMatrix& other) const { \ + template inline RectangularMatrix operator*(const RectangularMatrix& other) const { \ return Matrix::operator*(other); \ } \ inline VectorType operator*(const Vector& other) const { \ @@ -223,12 +223,12 @@ template inline Corrade::Utility::Debug operator<<(Corrade namespace Implementation { -template class MatrixDeterminant { +template class MatrixDeterminant { public: T operator()(const Matrix& m) { T out(0); - for(size_t col = 0; col != size; ++col) + for(std::size_t col = 0; col != size; ++col) out += ((col & 1) ? -1 : 1)*m(col, 0)*m.ij(col, 0).determinant(); return out; @@ -256,7 +256,7 @@ template class MatrixDeterminant<1, T> { namespace Corrade { namespace Utility { /** @configurationvalue{Magnum::Math::Matrix} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; + template struct ConfigurationValue>: public ConfigurationValue> {}; }} #endif diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h index 7c023931f..d0bea5345 100644 --- a/src/Math/RectangularMatrix.h +++ b/src/Math/RectangularMatrix.h @@ -28,28 +28,28 @@ namespace Magnum { namespace Math { -template class RectangularMatrix; +template class RectangularMatrix; #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { - template struct Sequence {}; + template struct Sequence {}; /* E.g. GenerateSequence<3>::Type is Sequence<0, 1, 2> */ - template struct GenerateSequence: + template struct GenerateSequence: GenerateSequence {}; - template struct GenerateSequence<0, sequence...> { + template struct GenerateSequence<0, sequence...> { typedef Sequence Type; }; /* Implementation for RectangularMatrix::from(const RectangularMatrix&) */ - template inline constexpr Math::RectangularMatrix rectangularMatrixFrom(Sequence, const Math::RectangularMatrix& matrix) { + template inline constexpr Math::RectangularMatrix rectangularMatrixFrom(Sequence, const Math::RectangularMatrix& matrix) { return {T(matrix.data()[sequence])...}; } } #endif -template class Vector; +template class Vector; /** @brief Rectangular matrix @@ -60,13 +60,13 @@ template class Vector; See @ref matrix-vector for brief introduction. See also Matrix (square) and Vector. */ -template class RectangularMatrix { +template class RectangularMatrix { static_assert(cols != 0 && rows != 0, "Matrix cannot have zero elements"); public: - typedef T Type; /**< @brief Data type */ - const static size_t Cols = cols; /**< @brief %Matrix column count */ - const static size_t Rows = rows; /**< @brief %Matrix row count */ + typedef T Type; /**< @brief Data type */ + const static std::size_t Cols = cols; /**< @brief %Matrix column count */ + const static std::size_t Rows = rows; /**< @brief %Matrix row count */ /** * @brief %Matrix from array @@ -148,11 +148,11 @@ template class RectangularMatrix { * For accessing individual elements prefer to use operator(), as it * is guaranteed to not involve unnecessary conversions. */ - inline Vector& operator[](size_t col) { + inline Vector& operator[](std::size_t col) { return Vector::from(_data+col*rows); } /** @overload */ - inline constexpr const Vector& operator[](size_t col) const { + inline constexpr const Vector& operator[](std::size_t col) const { return Vector::from(_data+col*rows); } @@ -162,17 +162,17 @@ template class RectangularMatrix { * Prefer this instead of using `[][]`. * @see operator[] */ - inline T& operator()(size_t col, size_t row) { + inline T& operator()(std::size_t col, std::size_t row) { return _data[col*rows+row]; } /** @overload */ - inline constexpr const T& operator()(size_t col, size_t row) const { + inline constexpr const T& operator()(std::size_t col, std::size_t row) const { return _data[col*rows+row]; } /** @brief Equality operator */ inline bool operator==(const RectangularMatrix& other) const { - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) if(!MathTypeTraits::equals(_data[i], other._data[i])) return false; return true; @@ -199,7 +199,7 @@ template class RectangularMatrix { * in-place. */ RectangularMatrix& operator+=(const RectangularMatrix& other) { - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) _data[i] += other._data[i]; return *this; @@ -209,7 +209,7 @@ template class RectangularMatrix { RectangularMatrix operator-() const { RectangularMatrix out; - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) out._data[i] = -_data[i]; return out; @@ -231,7 +231,7 @@ template class RectangularMatrix { * in-place. */ RectangularMatrix& operator-=(const RectangularMatrix& other) { - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) _data[i] -= other._data[i]; return *this; @@ -261,7 +261,7 @@ template class RectangularMatrix { #else template RectangularMatrix& operator*=(U number) { #endif - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) _data[i] *= number; return *this; @@ -291,19 +291,19 @@ template class RectangularMatrix { #else template RectangularMatrix& operator/=(U number) { #endif - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) _data[i] /= number; return *this; } /** @brief Multiply matrix */ - template RectangularMatrix operator*(const RectangularMatrix& other) const { + template RectangularMatrix operator*(const RectangularMatrix& other) const { RectangularMatrix out; - for(size_t col = 0; col != size; ++col) - for(size_t row = 0; row != rows; ++row) - for(size_t pos = 0; pos != cols; ++pos) + for(std::size_t col = 0; col != size; ++col) + for(std::size_t row = 0; row != rows; ++row) + for(std::size_t pos = 0; pos != cols; ++pos) out(col, row) += (*this)(pos, row)*other(col, pos); return out; @@ -323,8 +323,8 @@ template class RectangularMatrix { RectangularMatrix transposed() const { RectangularMatrix out; - for(size_t col = 0; col != cols; ++col) - for(size_t row = 0; row != rows; ++row) + for(std::size_t col = 0; col != cols; ++col) + for(std::size_t row = 0; row != rows; ++row) out(row, col) = (*this)(col, row); return out; @@ -336,10 +336,10 @@ template class RectangularMatrix { #endif private: - template inline constexpr static RectangularMatrix from(Implementation::Sequence s, const Vector& first, U... next) { + template inline constexpr static RectangularMatrix from(Implementation::Sequence s, const Vector& first, U... next) { return from(s, next..., first[sequence]...); } - template inline constexpr static RectangularMatrix from(Implementation::Sequence, T first, U... next) { + template inline constexpr static RectangularMatrix from(Implementation::Sequence, T first, U... next) { return RectangularMatrix(first, next...); } }; @@ -350,9 +350,9 @@ template class RectangularMatrix { @see RectangularMatrix::operator*(U) const */ #ifndef DOXYGEN_GENERATING_OUTPUT -template inline typename std::enable_if::value, RectangularMatrix>::type operator*(U number, const RectangularMatrix& matrix) { +template inline typename std::enable_if::value, RectangularMatrix>::type operator*(U number, const RectangularMatrix& matrix) { #else -template inline RectangularMatrix operator*(U number, const RectangularMatrix& matrix) { +template inline RectangularMatrix operator*(U number, const RectangularMatrix& matrix) { #endif return matrix*number; } @@ -368,25 +368,25 @@ RectangularMatrix<2, 3, float> another = 1.0f/mat; // {1.0f, 0.5f, -0.25f, 0.128 @see RectangularMatrix::operator/() */ #ifndef DOXYGEN_GENERATING_OUTPUT -template typename std::enable_if::value, RectangularMatrix>::type operator/(U number, const RectangularMatrix& matrix) { +template typename std::enable_if::value, RectangularMatrix>::type operator/(U number, const RectangularMatrix& matrix) { #else -template RectangularMatrix operator/(U number, const RectangularMatrix& matrix) { +template RectangularMatrix operator/(U number, const RectangularMatrix& matrix) { #endif RectangularMatrix out; - for(size_t i = 0; i != cols*rows; ++i) + for(std::size_t i = 0; i != cols*rows; ++i) out.data()[i] = number/matrix.data()[i]; return out; } /** @debugoperator{Magnum::Math::RectangularMatrix} */ -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::RectangularMatrix& value) { +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::RectangularMatrix& value) { debug << "Matrix("; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); - for(size_t row = 0; row != rows; ++row) { + for(std::size_t row = 0; row != rows; ++row) { if(row != 0) debug << ",\n "; - for(size_t col = 0; col != cols; ++col) { + for(std::size_t col = 0; col != cols; ++col) { if(col != 0) debug << ", "; debug << typename MathTypeTraits::NumericType(value[col][row]); } @@ -455,13 +455,13 @@ template Corrade::Utility::Debug operator<<(C namespace Corrade { namespace Utility { /** @configurationvalue{Magnum::Math::RectangularMatrix} */ -template struct ConfigurationValue> { +template struct ConfigurationValue> { /** @brief Writes elements separated with spaces */ static std::string toString(const Magnum::Math::RectangularMatrix& value, int flags = 0) { std::string output; - for(size_t row = 0; row != rows; ++row) { - for(size_t col = 0; col != cols; ++col) { + for(std::size_t row = 0; row != rows; ++row) { + for(std::size_t col = 0; col != cols; ++col) { if(!output.empty()) output += ' '; output += ConfigurationValue::toString(value(col, row), flags); } @@ -475,8 +475,8 @@ template struct ConfigurationValue result; std::istringstream in(stringValue); - for(size_t row = 0; row != rows; ++row) { - for(size_t col = 0; col != cols; ++col) { + for(std::size_t row = 0; row != rows; ++row) { + for(std::size_t col = 0; col != cols; ++col) { std::string num; in >> num; result(col, row) = ConfigurationValue::fromString(num, flags); diff --git a/src/Math/Vector.h b/src/Math/Vector.h index e0d5ab5e0..ba9651ba0 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -31,9 +31,9 @@ namespace Magnum { namespace Math { See @ref matrix-vector for brief introduction. @configurationvalueref{Magnum::Math::Vector} */ -template class Vector: public RectangularMatrix<1, size, T> { +template class Vector: public RectangularMatrix<1, size, T> { public: - const static size_t Size = size; /**< @brief %Vector size */ + const static std::size_t Size = size; /**< @brief %Vector size */ /** * @brief Dot product @@ -46,7 +46,7 @@ template class Vector: public RectangularMatrix<1, size, T static T dot(const Vector& a, const Vector& b) { T out(0); - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) out += a[i]*b[i]; return out; @@ -90,7 +90,7 @@ template class Vector: public RectangularMatrix<1, size, T #else inline explicit Vector(T value) { #endif - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) (*this)[i] = value; } @@ -98,8 +98,8 @@ template class Vector: public RectangularMatrix<1, size, T inline constexpr Vector(const RectangularMatrix<1, size, T>& other): RectangularMatrix<1, size, T>(other) {} /** @brief Value at given position */ - inline T& operator[](size_t pos) { return RectangularMatrix<1, size, T>::_data[pos]; } - inline constexpr T operator[](size_t pos) const { return RectangularMatrix<1, size, T>::_data[pos]; } /**< @overload */ + inline T& operator[](std::size_t pos) { return RectangularMatrix<1, size, T>::_data[pos]; } + inline constexpr T operator[](std::size_t pos) const { return RectangularMatrix<1, size, T>::_data[pos]; } /**< @overload */ /** * @brief Multiply vector component-wise @@ -117,7 +117,7 @@ template class Vector: public RectangularMatrix<1, size, T * because it does the computation in-place. */ Vector& operator*=(const Vector& other) { - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) (*this)[i] *= other[i]; return *this; @@ -139,7 +139,7 @@ template class Vector: public RectangularMatrix<1, size, T * because it does the computation in-place. */ Vector& operator/=(const Vector& other) { - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) (*this)[i] /= other[i]; return *this; @@ -177,7 +177,7 @@ template class Vector: public RectangularMatrix<1, size, T T sum() const { T out(0); - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) out += (*this)[i]; return out; @@ -187,7 +187,7 @@ template class Vector: public RectangularMatrix<1, size, T T product() const { T out(1); - for(size_t i = 0; i != size; ++i) + for(std::size_t i = 0; i != size; ++i) out *= (*this)[i]; return out; @@ -197,7 +197,7 @@ template class Vector: public RectangularMatrix<1, size, T T min() const { T out((*this)[0]); - for(size_t i = 1; i != size; ++i) + for(std::size_t i = 1; i != size; ++i) out = std::min(out, (*this)[i]); return out; @@ -207,7 +207,7 @@ template class Vector: public RectangularMatrix<1, size, T T max() const { T out((*this)[0]); - for(size_t i = 1; i != size; ++i) + for(std::size_t i = 1; i != size; ++i) out = std::max(out, (*this)[i]); return out; @@ -215,7 +215,7 @@ template class Vector: public RectangularMatrix<1, size, T #ifndef DOXYGEN_GENERATING_OUTPUT /* Reimplementation of functions to return correct type */ - template inline RectangularMatrix operator*(const RectangularMatrix& other) const { + template inline RectangularMatrix operator*(const RectangularMatrix& other) const { return RectangularMatrix<1, size, T>::operator*(other); } MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(1, size, Vector) @@ -231,19 +231,19 @@ template class Vector: public RectangularMatrix<1, size, T }; #ifndef DOXYGEN_GENERATING_OUTPUT -template inline typename std::enable_if::value, Vector>::type operator*(U number, const Vector& vector) { +template inline typename std::enable_if::value, Vector>::type operator*(U number, const Vector& vector) { return number*RectangularMatrix<1, size, T>(vector); } -template inline typename std::enable_if::value, Vector>::type operator/(U number, const Vector& vector) { +template inline typename std::enable_if::value, Vector>::type operator/(U number, const Vector& vector) { return number/RectangularMatrix<1, size, T>(vector); } #endif /** @debugoperator{Magnum::Math::Vector} */ -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Vector& value) { +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Vector& value) { debug << "Vector("; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); - for(size_t i = 0; i != size; ++i) { + for(std::size_t i = 0; i != size; ++i) { if(i != 0) debug << ", "; debug << typename MathTypeTraits::NumericType(value[i]); } @@ -269,7 +269,7 @@ template Corrade::Utility::Debug operator<<(Corrade::Utili return *this; \ } \ \ - template inline Math::RectangularMatrix operator*(const Math::RectangularMatrix& other) const { \ + template inline Math::RectangularMatrix operator*(const Math::RectangularMatrix& other) const { \ return Math::Vector::operator*(other); \ } \ inline Type operator*(const Math::Vector& other) const { \ @@ -303,7 +303,7 @@ template Corrade::Utility::Debug operator<<(Corrade::Utili namespace Corrade { namespace Utility { /** @configurationvalue{Magnum::Math::Vector} */ -template struct ConfigurationValue>: public ConfigurationValue> {}; +template struct ConfigurationValue>: public ConfigurationValue> {}; }} diff --git a/src/MeshTools/Clean.h b/src/MeshTools/Clean.h index 8c4389062..fdd5c552f 100644 --- a/src/MeshTools/Clean.h +++ b/src/MeshTools/Clean.h @@ -31,7 +31,7 @@ namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { -template class Clean { +template class Clean { public: inline Clean(std::vector& indices, std::vector& vertices): indices(indices), vertices(vertices) {} @@ -40,32 +40,32 @@ template class Clean { /* Get mesh bounds */ Vertex min, max; - for(size_t i = 0; i != Vertex::Size; ++i) { + for(std::size_t i = 0; i != Vertex::Size; ++i) { min[i] = std::numeric_limits::max(); max[i] = std::numeric_limits::min(); } for(auto it = vertices.cbegin(); it != vertices.cend(); ++it) - for(size_t i = 0; i != vertexSize; ++i) + for(std::size_t i = 0; i != vertexSize; ++i) if((*it)[i] < min[i]) min[i] = (*it)[i]; else if((*it)[i] > max[i]) max[i] = (*it)[i]; - /* Make epsilon so large that size_t can index all vertices inside - mesh bounds. */ + /* Make epsilon so large that std::size_t can index all vertices + inside mesh bounds. */ Vertex size = max-min; - for(size_t i = 0; i != Vertex::Size; ++i) - if(static_cast(size[i]/std::numeric_limits::max()) > epsilon) - epsilon = static_cast(size[i]/std::numeric_limits::max()); + for(std::size_t i = 0; i != Vertex::Size; ++i) + if(static_cast(size[i]/std::numeric_limits::max()) > epsilon) + epsilon = static_cast(size[i]/std::numeric_limits::max()); /* First go with original vertex coordinates, then move them by epsilon/2 in each direction. */ Vertex moved; - for(size_t moving = 0; moving <= vertexSize; ++moving) { + for(std::size_t moving = 0; moving <= vertexSize; ++moving) { /* Under each index is pointer to face which contains given vertex and index of vertex in the face. */ - std::unordered_map, HashedVertex, IndexHash> table; + std::unordered_map, HashedVertex, IndexHash> table; /* Reserve space for all vertices */ table.reserve(vertices.size()); @@ -73,15 +73,15 @@ template class Clean { /* Go through all faces' vertices */ for(auto it = indices.begin(); it != indices.end(); ++it) { /* Index of a vertex in vertexSize-dimensional table */ - size_t index[vertexSize]; - for(size_t ii = 0; ii != vertexSize; ++ii) + std::size_t index[vertexSize]; + for(std::size_t ii = 0; ii != vertexSize; ++ii) index[ii] = (vertices[*it][ii]+moved[ii]-min[ii])/epsilon; /* Try inserting the vertex into table, if it already exists, change vertex pointer of the face to already existing vertex */ HashedVertex v(*it, table.size()); - auto result = table.insert(std::pair, HashedVertex>(Math::Vector::from(index), v)); + auto result = table.insert(std::pair, HashedVertex>(Math::Vector::from(index), v)); *it = result.first->second.newIndex; } @@ -102,8 +102,8 @@ template class Clean { private: class IndexHash { public: - inline size_t operator()(const Math::Vector& data) const { - return *reinterpret_cast(Corrade::Utility::MurmurHash2()(reinterpret_cast(&data), sizeof(data)).byteArray()); + inline std::size_t operator()(const Math::Vector& data) const { + return *reinterpret_cast(Corrade::Utility::MurmurHash2()(reinterpret_cast(&data), sizeof(data)).byteArray()); } }; @@ -137,7 +137,7 @@ Removes duplicate vertices from the mesh. @todo Interpolate vertices, not collapse them to first in the cell @todo Ability to specify other attributes for interpolation */ -template inline void clean(std::vector& indices, std::vector& vertices, typename Vertex::Type epsilon = TypeTraits::epsilon()) { +template inline void clean(std::vector& indices, std::vector& vertices, typename Vertex::Type epsilon = TypeTraits::epsilon()) { Implementation::Clean(indices, vertices)(epsilon); } diff --git a/src/MeshTools/CombineIndexedArrays.h b/src/MeshTools/CombineIndexedArrays.h index 25a8cca4e..39110a722 100644 --- a/src/MeshTools/CombineIndexedArrays.h +++ b/src/MeshTools/CombineIndexedArrays.h @@ -35,7 +35,7 @@ class CombineIndexedArrays { public: template std::vector operator()(const std::tuple&, std::vector&>&... indexedArrays) { /* Compute index count */ - size_t _indexCount = indexCount(std::get<0>(indexedArrays)...); + std::size_t _indexCount = indexCount(std::get<0>(indexedArrays)...); /* Resulting index array */ std::vector result; @@ -56,24 +56,24 @@ class CombineIndexedArrays { } private: - template inline static size_t indexCount(const std::vector& first, const std::vector&... next) { + template inline static std::size_t indexCount(const std::vector& first, const std::vector&... next) { CORRADE_ASSERT(sizeof...(next) == 0 || indexCount(next...) == first.size(), "MeshTools::combineIndexedArrays(): index arrays don't have the same length, nothing done.", 0); return first.size(); } - template static void writeCombinedIndices(std::vector>& output, const std::vector& first, const std::vector&... next) { + template static void writeCombinedIndices(std::vector>& output, const std::vector& first, const std::vector&... next) { /* Copy the data to output */ - for(size_t i = 0; i != output.size(); ++i) + for(std::size_t i = 0; i != output.size(); ++i) output[i][size-sizeof...(next)-1] = first[i]; writeCombinedIndices(output, next...); } - template static void writeCombinedArrays(const std::vector>& combinedIndices, std::vector& first, std::vector&... next) { + template static void writeCombinedArrays(const std::vector>& combinedIndices, std::vector& first, std::vector&... next) { /* Rewrite output array */ std::vector output; - for(size_t i = 0; i != combinedIndices.size(); ++i) + for(std::size_t i = 0; i != combinedIndices.size(); ++i) output.push_back(first[combinedIndices[i][size-sizeof...(next)-1]]); std::swap(output, first); @@ -81,9 +81,9 @@ class CombineIndexedArrays { } /* Terminator functions for recursive calls */ - inline static size_t indexCount() { return 0; } - template inline static void writeCombinedIndices(std::vector>&) {} - template inline static void writeCombinedArrays(const std::vector>&) {} + inline static std::size_t indexCount() { return 0; } + template inline static void writeCombinedIndices(std::vector>&) {} + template inline static void writeCombinedArrays(const std::vector>&) {} }; } diff --git a/src/MeshTools/CompressIndices.cpp b/src/MeshTools/CompressIndices.cpp index 445f5378f..213760226 100644 --- a/src/MeshTools/CompressIndices.cpp +++ b/src/MeshTools/CompressIndices.cpp @@ -22,6 +22,8 @@ #include "IndexedMesh.h" #include "SizeTraits.h" +using namespace std; + namespace Magnum { namespace MeshTools { #ifndef DOXYGEN_GENERATING_OUTPUT diff --git a/src/MeshTools/CompressIndices.h b/src/MeshTools/CompressIndices.h index 1890d3af8..c4ea6c0c0 100644 --- a/src/MeshTools/CompressIndices.h +++ b/src/MeshTools/CompressIndices.h @@ -39,13 +39,13 @@ class MESHTOOLS_EXPORT CompressIndices { public: CompressIndices(const std::vector& indices): indices(indices) {} - std::tuple operator()() const; + std::tuple operator()() const; void operator()(IndexedMesh* mesh, Buffer::Usage usage) const; private: struct Compressor { - template static std::tuple run(const std::vector& indices); + template static std::tuple run(const std::vector& indices); }; const std::vector& indices; @@ -66,11 +66,11 @@ wasteful to store them in array of `unsigned int`s, array of `unsigned short`s is sufficient. Size of the buffer can be computed from index count and type, as shown below. Example usage: @code -size_t indexCount; +std::size_t indexCount; Type indexType; char* data; std::tie(indexCount, indexType, data) = MeshTools::compressIndices(indices); -size_t dataSize = indexCount*TypeInfo::sizeOf(indexType); +std::size_t dataSize = indexCount*TypeInfo::sizeOf(indexType); // ... delete[] data; @endcode @@ -78,7 +78,7 @@ delete[] data; See also compressIndices(IndexedMesh*, Buffer::Usage, const std::vector&), which writes the compressed data directly into index buffer of given mesh. */ -inline std::tuple compressIndices(const std::vector& indices) { +inline std::tuple compressIndices(const std::vector& indices) { return Implementation::CompressIndices{indices}(); } diff --git a/src/MeshTools/Interleave.h b/src/MeshTools/Interleave.h index f345e0cb2..44451174f 100644 --- a/src/MeshTools/Interleave.h +++ b/src/MeshTools/Interleave.h @@ -36,7 +36,7 @@ class Interleave { public: inline Interleave(): _attributeCount(0), _stride(0), _data(nullptr) {} - template std::tuple operator()(const T&... attributes) { + template std::tuple operator()(const T&... attributes) { /* Compute buffer size and stride */ _attributeCount = attributeCount(attributes...); if(_attributeCount) { @@ -69,13 +69,13 @@ class Interleave { buffer->setData(attribute, usage); } - template inline static size_t attributeCount(const T& first, const U&... next) { + template inline static std::size_t attributeCount(const T& first, const U&... next) { CORRADE_ASSERT(sizeof...(next) == 0 || attributeCount(next...) == first.size(), "MeshTools::interleave(): attribute arrays don't have the same length, nothing done.", 0); return first.size(); } - template inline static size_t stride(const T&, const U&... next) { + template inline static std::size_t stride(const T&, const U&... next) { return sizeof(typename T::value_type) + stride(next...); } @@ -83,19 +83,19 @@ class Interleave { template void write(char* startingOffset, const T& first, const U&... next) { /* Copy the data to the buffer */ auto it = first.begin(); - for(size_t i = 0; i != _attributeCount; ++i, ++it) + for(std::size_t i = 0; i != _attributeCount; ++i, ++it) memcpy(startingOffset+i*_stride, reinterpret_cast(&*it), sizeof(typename T::value_type)); write(startingOffset+sizeof(typename T::value_type), next...); } /* Terminator functions for recursive calls */ - inline static size_t attributeCount() { return 0; } - inline static size_t stride() { return 0; } + inline static std::size_t attributeCount() { return 0; } + inline static std::size_t stride() { return 0; } inline void write(char*) {} - size_t _attributeCount; - size_t _stride; + std::size_t _attributeCount; + std::size_t _stride; char* _data; }; @@ -116,11 +116,11 @@ usage: @code std::vector positions; std::vector textureCoordinates; -size_t attributeCount; -size_t stride; +std::size_t attributeCount; +std::size_t stride; char* data; std::tie(attributeCount, stride, data) = MeshTools::interleave(positions, textureCoordinates); -size_t dataSize = attributeCount*stride; +std::size_t dataSize = attributeCount*stride; // ... delete[] data; @endcode @@ -137,7 +137,7 @@ which writes the interleaved array directly into buffer of given mesh. array has zero length. */ /* enable_if to avoid clash with overloaded function below */ -template inline typename std::enable_if::value, std::tuple>::type interleave(const T& attribute, const U&... attributes) { +template inline typename std::enable_if::value, std::tuple>::type interleave(const T& attribute, const U&... attributes) { return Implementation::Interleave()(attribute, attributes...); } diff --git a/src/MeshTools/Subdivide.h b/src/MeshTools/Subdivide.h index ab2c27dc8..690362362 100644 --- a/src/MeshTools/Subdivide.h +++ b/src/MeshTools/Subdivide.h @@ -34,11 +34,11 @@ template class Subdivide { void operator()(Interpolator interpolator) { CORRADE_ASSERT(!(indices.size()%3), "MeshTools::subdivide(): index count is not divisible by 3!", ); - size_t indexCount = indices.size(); + std::size_t indexCount = indices.size(); indices.reserve(indices.size()*4); /* Subdivide each face to four new */ - for(size_t i = 0; i != indexCount; i += 3) { + for(std::size_t i = 0; i != indexCount; i += 3) { /* Interpolate each side */ unsigned int newVertices[3]; for(int j = 0; j != 3; ++j) @@ -60,7 +60,7 @@ template class Subdivide { addFace(indices[i], newVertices[0], newVertices[2]); addFace(newVertices[0], indices[i+1], newVertices[1]); addFace(newVertices[2], newVertices[1], indices[i+2]); - for(size_t j = 0; j != 3; ++j) + for(std::size_t j = 0; j != 3; ++j) indices[i+j] = newVertices[j]; } } diff --git a/src/MeshTools/Test/CleanTest.h b/src/MeshTools/Test/CleanTest.h index f24e4730e..1500ad601 100644 --- a/src/MeshTools/Test/CleanTest.h +++ b/src/MeshTools/Test/CleanTest.h @@ -28,13 +28,13 @@ class CleanTest: public Corrade::TestSuite::Tester { private: class Vector1 { public: - static const size_t Size = 1; + static const std::size_t Size = 1; typedef int Type; Vector1(): data(0) {} Vector1(int i): data(i) {} - int operator[](size_t) const { return data; } - int& operator[](size_t) { return data; } + int operator[](std::size_t) const { return data; } + int& operator[](std::size_t) { return data; } bool operator==(Vector1 i) const { return i.data == data; } Vector1 operator-(Vector1 i) const { return data-i.data; } diff --git a/src/MeshTools/Test/SubdivideTest.h b/src/MeshTools/Test/SubdivideTest.h index bc7569cb5..1ed5cc4f0 100644 --- a/src/MeshTools/Test/SubdivideTest.h +++ b/src/MeshTools/Test/SubdivideTest.h @@ -29,13 +29,13 @@ class SubdivideTest: public Corrade::TestSuite::Tester { private: class Vector1 { public: - static const size_t Size = 1; + static const std::size_t Size = 1; typedef int Type; Vector1(): data(0) {} Vector1(int i): data(i) {} - int operator[](size_t) const { return data; } - int& operator[](size_t) { return data; } + int operator[](std::size_t) const { return data; } + int& operator[](std::size_t) { return data; } bool operator==(Vector1 i) const { return i.data == data; } Vector1 operator-(Vector1 i) const { return data-i.data; } diff --git a/src/MeshTools/Test/TipsifyTest.h b/src/MeshTools/Test/TipsifyTest.h index 939f6ae5a..12928f852 100644 --- a/src/MeshTools/Test/TipsifyTest.h +++ b/src/MeshTools/Test/TipsifyTest.h @@ -28,7 +28,7 @@ class TipsifyTest: public Corrade::TestSuite::Tester { private: std::vector indices; - size_t vertexCount; + std::size_t vertexCount; }; }}} diff --git a/src/MeshTools/Tipsify.h b/src/MeshTools/Tipsify.h index d43f4e926..39b3ed092 100644 --- a/src/MeshTools/Tipsify.h +++ b/src/MeshTools/Tipsify.h @@ -33,7 +33,7 @@ class MESHTOOLS_EXPORT Tipsify { public: inline Tipsify(std::vector& indices, unsigned int vertexCount): indices(indices), vertexCount(vertexCount) {} - void operator()(size_t cacheSize); + void operator()(std::size_t cacheSize); /** * @brief Build vertex-triangle adjacency @@ -63,7 +63,7 @@ array for beter usage of post-transform vertex cache. Algorithm used: for Vertex Locality and Reduced Overdraw, SIGGRAPH 2007, http://gfx.cs.princeton.edu/pubs/Sander_2007_%3ETR/index.php*. */ -inline void tipsify(std::vector& indices, unsigned int vertexCount, size_t cacheSize) { +inline void tipsify(std::vector& indices, unsigned int vertexCount, std::size_t cacheSize) { Implementation::Tipsify(indices, vertexCount)(cacheSize); } diff --git a/src/MeshTools/Transform.h b/src/MeshTools/Transform.h index 7e09e59ae..9ad5b3ceb 100644 --- a/src/MeshTools/Transform.h +++ b/src/MeshTools/Transform.h @@ -34,7 +34,7 @@ std::vector vertices; MeshTools::transform(Matrix4::scaling({2.0f, 0.5f, 0.0f}), vertices); @endcode */ -template inline void transform(const Math::Matrix& matrix, U& vertices) { +template inline void transform(const Math::Matrix& matrix, U& vertices) { for(Math::Vector& vertex: vertices) vertex = matrix*vertex; } diff --git a/src/Primitives/Icosphere.h b/src/Primitives/Icosphere.h index c01589d65..3f938ba84 100644 --- a/src/Primitives/Icosphere.h +++ b/src/Primitives/Icosphere.h @@ -26,7 +26,7 @@ namespace Magnum { namespace Primitives { -template class Icosphere; +template class Icosphere; /** @brief 3D icosphere primitive with zero subdivisions @@ -48,14 +48,14 @@ template<> class Icosphere<0>: public Trade::MeshData3D { Indexed triangle mesh with normals. */ #ifndef DOXYGEN_GENERATING_OUTPUT -template class Icosphere: public Icosphere<0> { +template class Icosphere: public Icosphere<0> { #else -template class Icosphere { +template class Icosphere { #endif public: /** @brief Constructor */ Icosphere() { - for(size_t i = 0; i != subdivisions; ++i) + for(std::size_t i = 0; i != subdivisions; ++i) MeshTools::subdivide(*indices(), *normals(0), [](const Vector3& a, const Vector3& b) { return (a+b).normalized(); }); diff --git a/src/Profiler.h b/src/Profiler.h index b4f7f6306..1d52f14ed 100644 --- a/src/Profiler.h +++ b/src/Profiler.h @@ -115,7 +115,7 @@ class MAGNUM_EXPORT Profiler { * is 60. * @attention This function cannot be called if profiling is enabled. */ - void setMeasureDuration(size_t frames); + void setMeasureDuration(std::size_t frames); /** * @brief Add named section @@ -193,7 +193,7 @@ class MAGNUM_EXPORT Profiler { void save(); bool enabled; - size_t measureDuration, currentFrame, frameCount; + std::size_t measureDuration, currentFrame, frameCount; std::vector sections; std::vector frameData; std::vector totalData; diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 919bc810c..d4b1db993 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -106,7 +106,7 @@ class ResourceKey: public Corrade::Utility::MurmurHash2::Digest { * @brief Constructor * @todo constexpr */ - template inline constexpr ResourceKey(const char(&key)[size]): Corrade::Utility::MurmurHash2::Digest(Corrade::Utility::MurmurHash2()(key)) {} + template inline constexpr ResourceKey(const char(&key)[size]): Corrade::Utility::MurmurHash2::Digest(Corrade::Utility::MurmurHash2()(key)) {} }; template class Resource; @@ -114,8 +114,8 @@ template class Resource; #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { struct ResourceKeyHash { - inline size_t operator()(ResourceKey key) const { - return *reinterpret_cast(key.byteArray()); + inline std::size_t operator()(ResourceKey key) const { + return *reinterpret_cast(key.byteArray()); } }; @@ -146,18 +146,18 @@ namespace Implementation { T* data; ResourceDataState state; ResourcePolicy policy; - size_t referenceCount; + std::size_t referenceCount; }; inline virtual ~ResourceManagerData() { delete _fallback; } - inline size_t lastChange() const { return _lastChange; } + inline std::size_t lastChange() const { return _lastChange; } - inline size_t count() const { return _data.size(); } + inline std::size_t count() const { return _data.size(); } - size_t referenceCount(ResourceKey key) const { + std::size_t referenceCount(ResourceKey key) const { auto it = _data.find(key); if(it == _data.end()) return 0; return it->second.referenceCount; @@ -243,7 +243,7 @@ namespace Implementation { private: std::unordered_map _data; T* _fallback; - size_t _lastChange; + std::size_t _lastChange; }; } #endif @@ -372,7 +372,7 @@ template class Resource { Implementation::ResourceManagerData* manager; ResourceKey _key; - size_t lastCheck; + std::size_t lastCheck; ResourceState _state; T* data; }; @@ -465,7 +465,7 @@ template class ResourceManager: protected Implementation::Resour inline ~ResourceManager() { _instance = nullptr; } /** @brief Count of resources of given type */ - template inline size_t count() { + template inline std::size_t count() { return this->Implementation::ResourceManagerData::count(); } @@ -490,7 +490,7 @@ template class ResourceManager: protected Implementation::Resour * * @see set() */ - template inline size_t referenceCount(ResourceKey key) const { + template inline std::size_t referenceCount(ResourceKey key) const { return this->Implementation::ResourceManagerData::referenceCount(key); } @@ -552,7 +552,7 @@ template class ResourceManager: protected Implementation::Resour /** @debugoperator{Magnum::ResourceKey} */ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const ResourceKey& value) { - return debug << static_cast&>(value); + return debug << static_cast&>(value); } template ResourceManager* ResourceManager::_instance(nullptr); diff --git a/src/SizeTraits.h b/src/SizeTraits.h index 62f984d39..4d4b28c09 100644 --- a/src/SizeTraits.h +++ b/src/SizeTraits.h @@ -39,7 +39,7 @@ to compute logarithms at compile time, e.g. `SizeTraits::%value>::%SizeType`. */ #ifdef DOXYGEN_GENERATING_OUTPUT -template struct SizeTraits { +template struct SizeTraits { /** * @brief (Unsigned) type able to index the data * @@ -49,7 +49,7 @@ template struct SizeTraits { typedef T SizeType; }; #else -template struct SizeTraits: public SizeTraits {}; +template struct SizeTraits: public SizeTraits {}; #endif #ifndef DOXYGEN_GENERATING_OUTPUT @@ -75,7 +75,7 @@ template<> struct SizeTraits<4> { If you have templated function which you want to call with type suitable for indexing data of some size, you will probably use cascade of IFs, like this: @code -size_t dataSize; +std::size_t dataSize; template Bar foo(Arg1 arg1, Arg2 arg2, ...); Bar bar; @@ -105,7 +105,7 @@ template struct SizeBasedCall: public Base { * @brief Constructor * @param size Data size */ - SizeBasedCall(size_t size): size(size) {} + SizeBasedCall(std::size_t size): size(size) {} /** * @brief Functor @@ -132,7 +132,7 @@ template struct SizeBasedCall: public Base { } private: - size_t size; + std::size_t size; }; /** diff --git a/src/Swizzle.h b/src/Swizzle.h index 308eee93a..49b0870b8 100644 --- a/src/Swizzle.h +++ b/src/Swizzle.h @@ -28,29 +28,29 @@ namespace Implementation { using Math::Implementation::Sequence; using Math::Implementation::GenerateSequence; - template struct ComponentAtPosition { + template struct ComponentAtPosition { static_assert(size > position, "Swizzle parameter out of range of base vector"); template inline constexpr static T value(const Math::Vector& vector) { return vector[position]; } }; - template struct Component {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component: public ComponentAtPosition {}; - template struct Component { + template struct Component {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component: public ComponentAtPosition {}; + template struct Component { template inline constexpr static T value(const Math::Vector&) { return T(0); } }; - template struct Component { + template struct Component { template inline constexpr static T value(const Math::Vector&) { return T(1); } }; - template struct TypeForSize { + template struct TypeForSize { typedef Math::Vector Type; }; template struct TypeForSize<2, T> { typedef Math::Vector2 Type; }; @@ -61,11 +61,11 @@ namespace Implementation { template struct TypeForSize<4, Color3> { typedef Color4 Type; }; template struct TypeForSize<4, Color4> { typedef Color4 Type; }; - template inline constexpr T componentAtPosition(const Math::Vector& vector, size_t position) { + template inline constexpr T componentAtPosition(const Math::Vector& vector, std::size_t position) { return size > position ? vector[position] : throw; } - template inline constexpr T component(const Math::Vector& vector, char component) { + template inline constexpr T component(const Math::Vector& vector, char component) { return component == 'x' ? componentAtPosition(vector, 0) : component == 'y' ? componentAtPosition(vector, 1) : component == 'z' ? componentAtPosition(vector, 2) : @@ -79,7 +79,7 @@ namespace Implementation { throw; } - template inline constexpr Math::Vector swizzleFrom(Sequence, const Math::Vector& vector, const char(&components)[sizeof...(sequence)+1]) { + template inline constexpr Math::Vector swizzleFrom(Sequence, const Math::Vector& vector, const char(&components)[sizeof...(sequence)+1]) { return {component(vector, components[sequence])...}; } } @@ -137,7 +137,7 @@ evaluated at compile time, but at runtime. @see @ref matrix-vector-component-access, Vector4::xyz(), Color4::rgb(), Vector4::xy(), Vector3::xy() */ -template inline constexpr typename Implementation::TypeForSize::Type swizzle(const T& vector, const char(&components)[newSize]) { +template inline constexpr typename Implementation::TypeForSize::Type swizzle(const T& vector, const char(&components)[newSize]) { return Implementation::swizzleFrom(typename Implementation::GenerateSequence::Type(), vector, components); } diff --git a/src/Test/ResourceManagerTest.h b/src/Test/ResourceManagerTest.h index 2f5ba5243..5d3364eb9 100644 --- a/src/Test/ResourceManagerTest.h +++ b/src/Test/ResourceManagerTest.h @@ -25,7 +25,7 @@ namespace Test { class Data { public: - static size_t count; + static std::size_t count; inline Data() { ++count; } inline ~Data() { --count; } diff --git a/src/TypeTraits.h b/src/TypeTraits.h index 5b15c9832..2f01b0167 100644 --- a/src/TypeTraits.h +++ b/src/TypeTraits.h @@ -25,8 +25,8 @@ namespace Magnum { namespace Math { - template class Vector; - template class Matrix; + template class Vector; + template class Matrix; } template class Color3; @@ -73,14 +73,14 @@ template struct TypeTraits: public Math::MathTypeTraits { * Returns sizeof(GLfloat) for GLfloat, but also sizeof(GLfloat) for * Vector3. See count(). */ - inline constexpr static size_t size(); + inline constexpr static std::size_t size(); /** * @brief Count of plain elements in this type * * Returns 1 for plain OpenGL types like GLint, but e.g. 3 for Vector3. */ - inline constexpr static size_t count(); + inline constexpr static std::size_t count(); }; #else template struct TypeTraits {}; @@ -137,11 +137,11 @@ struct MAGNUM_EXPORT TypeInfo { * These two lines provide the same information, one at compile time, * one at runtime: * @code - * size_t size = TypeTraits::size(); - * size_t size = TypeInfo::sizeOf(Type::UnsignedByte); + * std::size_t size = TypeTraits::size(); + * std::size_t size = TypeInfo::sizeOf(Type::UnsignedByte); * @endcode */ - static size_t sizeOf(Type type); + static std::size_t sizeOf(Type type); /** * @brief Whether the type is integral @@ -169,56 +169,56 @@ template<> struct TypeTraits: public Math::MathTypeTraits struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Byte; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Byte; } - inline constexpr static size_t size() { return sizeof(GLbyte); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLbyte); } + inline constexpr static std::size_t count() { return 1; } }; template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::UnsignedShort; } inline constexpr static Type indexType() { return Type::UnsignedShort; } inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedShort; } - inline constexpr static size_t size() { return sizeof(GLushort); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLushort); } + inline constexpr static std::size_t count() { return 1; } }; template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Short; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Short; } - inline constexpr static size_t size() { return sizeof(GLshort); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLshort); } + inline constexpr static std::size_t count() { return 1; } }; template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::UnsignedInt; } inline constexpr static Type indexType() { return Type::UnsignedInt; } inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::UnsignedInt; } - inline constexpr static size_t size() { return sizeof(GLuint); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLuint); } + inline constexpr static std::size_t count() { return 1; } }; template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Int; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Int; } - inline constexpr static size_t size() { return sizeof(GLint); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLint); } + inline constexpr static std::size_t count() { return 1; } }; template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Float; } /* Can not be used for indices */ inline constexpr static AbstractImage::ComponentType imageType() { return AbstractImage::ComponentType::Float; } - inline constexpr static size_t size() { return sizeof(GLfloat); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLfloat); } + inline constexpr static std::size_t count() { return 1; } }; #ifndef MAGNUM_TARGET_GLES @@ -226,17 +226,17 @@ template<> struct TypeTraits: public Math::MathTypeTraits { inline constexpr static Type type() { return Type::Double; } /* Can not be used for indices */ /* Can not be used for images */ - inline constexpr static size_t size() { return sizeof(GLdouble); } - inline constexpr static size_t count() { return 1; } + inline constexpr static std::size_t size() { return sizeof(GLdouble); } + inline constexpr static std::size_t count() { return 1; } }; #endif -template struct TypeTraits> { +template struct TypeTraits> { inline constexpr static Type type() { return TypeTraits::type(); } /* Can not be used for indices */ /* Can not be used for images */ - inline constexpr static size_t size() { return sizeof(T); } - inline constexpr static size_t count() { return vectorSize; } + inline constexpr static std::size_t size() { return sizeof(T); } + inline constexpr static std::size_t count() { return vectorSize; } }; template struct TypeTraits>: public TypeTraits> {}; @@ -247,12 +247,12 @@ template struct TypeTraits>: public TypeTraits struct TypeTraits>: public TypeTraits> {}; template struct TypeTraits>: public TypeTraits> {}; -template struct TypeTraits> { +template struct TypeTraits> { inline constexpr static Type type() { return TypeTraits::type(); } /* Can not be used for indices */ /* Can not be used for images */ - inline constexpr static size_t size() { return sizeof(T); } - inline constexpr static size_t count() { return matrixSize*matrixSize; } + inline constexpr static std::size_t size() { return sizeof(T); } + inline constexpr static std::size_t count() { return matrixSize*matrixSize; } }; template struct TypeTraits>: public TypeTraits> {};