From 07d11280e949f06fb905f6e8d6a1008d60531357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 29 Apr 2015 01:12:14 +0200 Subject: [PATCH] GCC 4.5 compatibility: no range-based for. --- src/Magnum/AbstractShaderProgram.cpp | 3 ++- src/Magnum/Platform/ScreenedApplication.hpp | 2 +- src/Magnum/SceneGraph/Object.hpp | 11 ++++++----- src/Magnum/SceneGraph/Test/ObjectTest.cpp | 8 ++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Magnum/AbstractShaderProgram.cpp b/src/Magnum/AbstractShaderProgram.cpp index 49671e309..8a0f30de0 100644 --- a/src/Magnum/AbstractShaderProgram.cpp +++ b/src/Magnum/AbstractShaderProgram.cpp @@ -319,7 +319,8 @@ void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_l Containers::Array names{outputs.size()}; Int i = 0; - for(const std::string& output: outputs) names[i++] = output.data(); + for(auto it = outputs.begin(); it != outputs.end(); ++it) + names[i++] = it->data(); glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode)); } diff --git a/src/Magnum/Platform/ScreenedApplication.hpp b/src/Magnum/Platform/ScreenedApplication.hpp index 869f5b6ea..ed3095bef 100644 --- a/src/Magnum/Platform/ScreenedApplication.hpp +++ b/src/Magnum/Platform/ScreenedApplication.hpp @@ -84,7 +84,7 @@ template void BasicScreenedApplication::viewport /* Call global event before all other (to resize framebuffer first) */ globalViewportEvent(size); - for(BasicScreen& s: *this) s.viewportEvent(size); + for(auto it = begin(*this); it != end(*this); ++it) (*it).viewportEvent(size); } template void BasicScreenedApplication::drawEvent() { diff --git a/src/Magnum/SceneGraph/Object.hpp b/src/Magnum/SceneGraph/Object.hpp index 5fcc56475..0c446a63b 100644 --- a/src/Magnum/SceneGraph/Object.hpp +++ b/src/Magnum/SceneGraph/Object.hpp @@ -171,12 +171,12 @@ template void Object::setDirty() { if(flags & Flag::Dirty) return; /* Make all features dirty */ - for(AbstractFeature& feature: this->features()) - feature.markDirty(); + for(auto it = begin(this->features()); it != end(this->features()); ++it) + (*it).markDirty(); /* Make all children dirty */ - for(Object& child: children()) - child.setDirty(); + for(auto it = begin(children()); it != end(children()); ++it) + (*it).setDirty(); /* Mark object as dirty */ flags |= Flag::Dirty; @@ -547,7 +547,8 @@ template void Object::setCleanInternal(con MatrixType matrix, invertedMatrix; /* Clean all features */ - for(AbstractFeature& feature: this->features()) { + for(auto it = begin(this->features()); it != end(this->features()); ++it) { + AbstractFeature& feature = *it; /* Cached absolute transformation, compute it if it wasn't computed already */ if(feature.cachedTransformations() & CachedTransformation::Absolute) { diff --git a/src/Magnum/SceneGraph/Test/ObjectTest.cpp b/src/Magnum/SceneGraph/Test/ObjectTest.cpp index d6b10655b..cc506bd05 100644 --- a/src/Magnum/SceneGraph/Test/ObjectTest.cpp +++ b/src/Magnum/SceneGraph/Test/ObjectTest.cpp @@ -512,7 +512,11 @@ void ObjectTest::rangeBasedForChildren() { Object3D c(&scene); std::vector objects; + #ifndef CORRADE_GCC45_COMPATIBILITY for(auto&& i: scene.children()) objects.push_back(&i); + #else + for(auto it = begin(scene.children()); it != end(scene.children()); ++it) objects.push_back(&*it); + #endif CORRADE_COMPARE(objects, (std::vector{&a, &b, &c})); } @@ -527,7 +531,11 @@ void ObjectTest::rangeBasedForFeatures() { Feature c(object); std::vector features; + #ifndef CORRADE_GCC45_COMPATIBILITY for(auto&& i: object.features()) features.push_back(&i); + #else + for(auto it = begin(object.features()); it != end(object.features()); ++it) features.push_back(&*it); + #endif CORRADE_COMPARE(features, (std::vector{&a, &b, &c})); }