From 74ba8460283c5db578ad236496c60403ba50525f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 17 Mar 2013 20:39:57 +0100 Subject: [PATCH] GCC 4.5 compatibility: no range-based for. --- src/DefaultFramebuffer.cpp | 8 ++++---- src/Framebuffer.cpp | 8 ++++---- src/MeshTools/Transform.h | 24 ++++++++++++++++-------- src/Platform/magnum-info.cpp | 5 ++++- src/Text/FreeTypeFont.cpp | 4 ++-- src/TextureTools/Atlas.cpp | 4 ++-- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/DefaultFramebuffer.cpp b/src/DefaultFramebuffer.cpp index 895a12e74..5e1c9e021 100644 --- a/src/DefaultFramebuffer.cpp +++ b/src/DefaultFramebuffer.cpp @@ -40,14 +40,14 @@ DefaultFramebuffer::DefaultFramebuffer() { _id = 0; } DefaultFramebuffer* DefaultFramebuffer::mapForDraw(std::initializer_list> attachments) { /* Max attachment location */ std::size_t max = 0; - for(const auto& attachment: attachments) - if(attachment.first > max) max = attachment.first; + for(auto it = attachments.begin(); it != attachments.end(); ++it) + if(it->first > max) max = it->first; /* Create linear array from associative */ GLenum* _attachments = new GLenum[max+1]; std::fill_n(_attachments, max, GL_NONE); - for(const auto& attachment: attachments) - _attachments[attachment.first] = static_cast(attachment.second); + for(auto it = attachments.begin(); it != attachments.end(); ++it) + _attachments[it->first] = static_cast(it->second); (this->*drawBuffersImplementation)(max+1, _attachments); delete[] _attachments; diff --git a/src/Framebuffer.cpp b/src/Framebuffer.cpp index 01c0a7d5f..ba3c1ddc6 100644 --- a/src/Framebuffer.cpp +++ b/src/Framebuffer.cpp @@ -70,14 +70,14 @@ Framebuffer::~Framebuffer() { Framebuffer* Framebuffer::mapForDraw(std::initializer_list> attachments) { /* Max attachment location */ std::size_t max = 0; - for(const auto& attachment: attachments) - if(attachment.first > max) max = attachment.first; + for(auto it = attachments.begin(); it != attachments.end(); ++it) + if(it->first > max) max = it->first; /* Create linear array from associative */ GLenum* _attachments = new GLenum[max+1]; std::fill_n(_attachments, max, GL_NONE); - for(const auto& attachment: attachments) - _attachments[attachment.first] = GLenum(attachment.second); + for(auto it = attachments.begin(); it != attachments.end(); ++it) + _attachments[it->first] = GLenum(it->second); (this->*drawBuffersImplementation)(max+1, _attachments); delete[] _attachments; diff --git a/src/MeshTools/Transform.h b/src/MeshTools/Transform.h index d04260275..f33498c7b 100644 --- a/src/MeshTools/Transform.h +++ b/src/MeshTools/Transform.h @@ -57,22 +57,26 @@ MeshTools::transformVectorsInPlace(rotation, vectors); @todo GPU transform feedback implementation (otherwise this is only bad joke) */ template void transformVectorsInPlace(const Math::Quaternion& normalizedQuaternion, U& vectors) { - for(auto& vector: vectors) vector = normalizedQuaternion.transformVectorNormalized(vector); + for(auto it = vectors.begin(); it != vectors.end(); ++it) + *it = normalizedQuaternion.transformVectorNormalized(*it); } /** @overload */ template void transformVectorsInPlace(const Math::Complex& complex, U& vectors) { - for(auto& vector: vectors) vector = complex.transformVector(vector); + for(auto it = vectors.begin(); it != vectors.end(); ++it) + *it = complex.transformVector(*it); } /** @overload */ template void transformVectorsInPlace(const Math::Matrix3& matrix, U& vectors) { - for(auto& vector: vectors) vector = matrix.transformVector(vector); + for(auto it = vectors.begin(); it != vectors.end(); ++it) + *it = matrix.transformVector(*it); } /** @overload */ template void transformVectorsInPlace(const Math::Matrix4& matrix, U& vectors) { - for(auto& vector: vectors) vector = matrix.transformVector(vector); + for(auto it = vectors.begin(); it != vectors.end(); ++it) + *it = matrix.transformVector(*it); } /** @@ -111,22 +115,26 @@ MeshTools::transformPointsInPlace(rotation, points); DualQuaternion::transformPointNormalized() */ template void transformPointsInPlace(const Math::DualQuaternion& normalizedDualQuaternion, U& points) { - for(auto& point: points) point = normalizedDualQuaternion.transformPointNormalized(point); + for(auto it = points.begin(); it != points.end(); ++it) + *it = normalizedDualQuaternion.transformPointNormalized(*it); } /** @overload */ template void transformPointsInPlace(const Math::DualComplex& dualComplex, U& points) { - for(auto& point: points) point = dualComplex.transformPoint(point); + for(auto it = points.begin(); it != points.end(); ++it) + *it = dualComplex.transformPoint(*it); } /** @overload */ template void transformPointsInPlace(const Math::Matrix3& matrix, U& points) { - for(auto& point: points) point = matrix.transformPoint(point); + for(auto it = points.begin(); it != points.end(); ++it) + *it = matrix.transformPoint(*it); } /** @overload */ template void transformPointsInPlace(const Math::Matrix4& matrix, U& points) { - for(auto& point: points) point = matrix.transformPoint(point); + for(auto it = points.begin(); it != points.end(); ++it) + *it = matrix.transformPoint(*it); } /** diff --git a/src/Platform/magnum-info.cpp b/src/Platform/magnum-info.cpp index 7aa18126b..ea7df8017 100644 --- a/src/Platform/magnum-info.cpp +++ b/src/Platform/magnum-info.cpp @@ -104,7 +104,10 @@ MagnumInfo::MagnumInfo(int& argc, char** argv): WindowlessGlxApplication(argc, a Debug() << versions[i] << "extension support:"; else Debug() << "Vendor extension support:"; - for(const auto& extension: Extension::extensions(versions[i])) { + auto extensions = Extension::extensions(versions[i]); + for(auto it = extensions.begin(); it != extensions.end(); ++it) { + const auto& extension = *it; + std::string extensionName = extension.string(); Debug d; d << " " << extensionName << std::string(60-extensionName.size(), ' '); diff --git a/src/Text/FreeTypeFont.cpp b/src/Text/FreeTypeFont.cpp index 4cd54b78c..a073006df 100644 --- a/src/Text/FreeTypeFont.cpp +++ b/src/Text/FreeTypeFont.cpp @@ -110,8 +110,8 @@ void FreeTypeFont::prerenderInternal(const std::string& characters, const Vector const Vector2i padding = Vector2i(radius); std::vector charSizes; charSizes.reserve(charIndices.size()); - for(FT_UInt c: charIndices) { - CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(_ftFont, c, FT_LOAD_DEFAULT) == 0); + for(auto it = charIndices.begin(); it != charIndices.end(); ++it) { + CORRADE_INTERNAL_ASSERT_OUTPUT(FT_Load_Glyph(_ftFont, *it, FT_LOAD_DEFAULT) == 0); charSizes.push_back(Vector2i(_ftFont->glyph->metrics.width, _ftFont->glyph->metrics.height)/64); } diff --git a/src/TextureTools/Atlas.cpp b/src/TextureTools/Atlas.cpp index 08398437c..36dd995a7 100644 --- a/src/TextureTools/Atlas.cpp +++ b/src/TextureTools/Atlas.cpp @@ -34,8 +34,8 @@ std::vector atlas(const Vector2i& atlasSize, const std::vector atlas;