From a7181f7a9bff28ae192c597c780206acde0d33d2 Mon Sep 17 00:00:00 2001 From: Michele Santullo Date: Fri, 14 Aug 2015 12:31:13 +0200 Subject: [PATCH] Build fix - cast index to size_t. --- include/doorkeeper/components/tilecoords.hpp | 3 +++ include/doorkeeper/implem/tilecoords.inl | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/doorkeeper/components/tilecoords.hpp b/include/doorkeeper/components/tilecoords.hpp index f7a9085..319337d 100644 --- a/include/doorkeeper/components/tilecoords.hpp +++ b/include/doorkeeper/components/tilecoords.hpp @@ -4,10 +4,13 @@ #include "doorkeeper/primitivetypes.hpp" #include "doorkeeper/implem/vector.hpp" #include +#include namespace dk { template class TileCoords { + static_assert(D >= 1, "Invalid dimension"); + static_assert(D <= static_cast(-1), "Dimension is too large"); public: typedef Vector coords; diff --git a/include/doorkeeper/implem/tilecoords.inl b/include/doorkeeper/implem/tilecoords.inl index 23d79a5..e7768dd 100644 --- a/include/doorkeeper/implem/tilecoords.inl +++ b/include/doorkeeper/implem/tilecoords.inl @@ -18,14 +18,14 @@ namespace dk { template TileCoords& TileCoords::operator++ () { const coords lower(0); - for (CoordinateDistType d = 0; d < D - 1; ++d) { + for (std::size_t d = 0; d < static_cast(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(D - 1)]; return *this; } @@ -39,7 +39,7 @@ namespace dk { template TileCoords& TileCoords::operator-- () { const coords lower(0); - for (CoordinateDistType d = 0; d < D; ++d) { + for (std::size_t d = 0; d < static_cast(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(D - 1)]; return *this; } @@ -63,7 +63,7 @@ namespace dk { const TileCoords& TileCoords::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];