Build fix - cast index to size_t.

This commit is contained in:
Michele Santullo 2015-08-14 12:31:13 +02:00
parent 8f77af0ac1
commit a7181f7a9b
2 changed files with 8 additions and 5 deletions

View file

@ -4,10 +4,13 @@
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/implem/vector.hpp"
#include <cstdint>
#include <cstddef>
namespace dk {
template <uint32_t D>
class TileCoords {
static_assert(D >= 1, "Invalid dimension");
static_assert(D <= static_cast<std::size_t>(-1), "Dimension is too large");
public:
typedef Vector<D> coords;

View file

@ -18,14 +18,14 @@ namespace dk {
template <uint32_t D>
TileCoords<D>& TileCoords<D>::operator++ () {
const coords lower(0);
for (CoordinateDistType d = 0; d < D - 1; ++d) {
for (std::size_t d = 0; d < static_cast<std::size_t>(D - 1); ++d) {
++m_pos[d];
if (m_pos[d] > m_size[d])
m_pos[d] = lower[d];
else
return *this;
}
++m_pos[D - 1];
++m_pos[static_cast<std::size_t>(D - 1)];
return *this;
}
@ -39,7 +39,7 @@ namespace dk {
template <uint32_t D>
TileCoords<D>& TileCoords<D>::operator-- () {
const coords lower(0);
for (CoordinateDistType d = 0; d < D; ++d) {
for (std::size_t d = 0; d < static_cast<std::size_t>(D); ++d) {
if (m_pos[d] > lower[d]) {
--m_pos[d];
return;
@ -48,7 +48,7 @@ namespace dk {
m_pos[d] = m_size[d];
}
}
++m_pos[D - 1];
++m_pos[static_cast<std::size_t>(D - 1)];
return *this;
}
@ -63,7 +63,7 @@ namespace dk {
const TileCoords<D>& TileCoords<D>::operator+= (CoordinateScalarType parValue) {
CoordinateScalarType acc(parValue);
CoordinateScalarType div(1);
for (uint32_t z = 0; z < D; ++z) {
for (std::size_t z = 0; z < D; ++z) {
m_pos[z] = (m_pos[z] + acc / div) % m_size[z];
div *= m_size[z];
acc += m_pos[z];