Browse Source

GCC 4.5 compatibility: no range-based for.

Vladimír Vondruš 12 years ago
parent
commit
d2229917f8
  1. 3
      src/Magnum/Implementation/State.cpp
  2. 9
      src/Magnum/MeshTools/RemoveDuplicates.h
  3. 36
      src/Magnum/SceneGraph/Object.hpp

3
src/Magnum/Implementation/State.cpp

@ -65,7 +65,8 @@ State::State(Context& context) {
extensions.erase(std::unique(extensions.begin(), extensions.end()), extensions.end());
Debug() << "Using optional features:";
for(const auto& ext: extensions) Debug() << " " << ext;
for(auto it = extensions.begin(); it != extensions.end(); ++it)
Debug() << " " << *it;
}
State::~State() {

9
src/Magnum/MeshTools/RemoveDuplicates.h

@ -101,9 +101,9 @@ std::vector<UnsignedInt> indices = MeshTools::combineIndexedArrays(
template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vector>& data, typename Vector::Type epsilon = Math::TypeTraits<typename Vector::Type>::epsilon()) {
/* Get bounds */
Vector min = data[0], max = data[0];
for(const auto& v: data) {
min = Math::min(v, min);
max = Math::max(v, max);
for(auto it = data.begin(); it != data.end(); ++it) {
min = Math::min(*it, min);
max = Math::max(*it, max);
}
/* Make epsilon so large that std::size_t can index all vectors inside the
@ -150,7 +150,8 @@ template<class Vector> std::vector<UnsignedInt> removeDuplicates(std::vector<Vec
data.resize(table.size());
/* Remap the resulting index array */
for(auto& i: resultIndices) i = indices[i];
for(auto it = resultIndices.begin(); it != resultIndices.end(); ++it)
*it = indices[*it];
/* Finished */
if(moving == Vector::Size) continue;

36
src/Magnum/SceneGraph/Object.hpp

@ -42,9 +42,9 @@ namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> void AbstractObject<dimensions, T>::setClean(const std::vector<AbstractObject<dimensions, T>*>& objects) {
std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>> references;
references.reserve(objects.size());
for(auto o: objects) {
CORRADE_INTERNAL_ASSERT(o != nullptr);
references.push_back(*o);
for(auto it = objects.begin(); it != objects.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it != nullptr);
references.push_back(**it);
}
setClean(references);
@ -64,9 +64,9 @@ template<UnsignedInt dimensions, class T> AbstractObject<dimensions, T>::~Abstra
template<UnsignedInt dimensions, class T> auto AbstractObject<dimensions, T>::transformationMatrices(const std::vector<AbstractObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> {
std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>> references;
references.reserve(objects.size());
for(auto o: objects) {
CORRADE_INTERNAL_ASSERT(o != nullptr);
references.push_back(*o);
for(auto it = objects.begin(); it != objects.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it != nullptr);
references.push_back(**it);
}
return transformationMatrices(references, initialTransformationMatrix);
@ -207,7 +207,8 @@ template<class Transformation> auto Object<Transformation>::doTransformationMatr
std::vector<std::reference_wrapper<Object<Transformation>>> castObjects;
castObjects.reserve(objects.size());
/** @todo Ensure this doesn't crash, somehow */
for(auto o: objects) castObjects.push_back(static_cast<Object<Transformation>&>(o.get()));
for(auto it = objects.begin(); it != objects.end(); ++it)
castObjects.push_back(static_cast<Object<Transformation>&>(it->get()));
return transformationMatrices(std::move(castObjects), initialTransformationMatrix);
}
@ -225,9 +226,9 @@ template<class Transformation> auto Object<Transformation>::transformationMatric
template<class Transformation> auto Object<Transformation>::transformationMatrices(const std::vector<Object<Transformation>*>& objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> {
std::vector<std::reference_wrapper<Object<Transformation>>> references;
references.reserve(objects.size());
for(auto o: objects) {
CORRADE_INTERNAL_ASSERT(o != nullptr);
references.push_back(*o);
for(auto it = objects.begin(); it != objects.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it != nullptr);
references.push_back(**it);
}
return transformationMatrices(references, initialTransformationMatrix);
@ -358,9 +359,9 @@ template<class Transformation> std::vector<typename Transformation::DataType> Ob
template<class Transformation> std::vector<typename Transformation::DataType> Object<Transformation>::transformations(const std::vector<Object<Transformation>*>& objects, const typename Transformation::DataType& initialTransformation) const {
std::vector<std::reference_wrapper<Object<Transformation>>> references;
references.reserve(objects.size());
for(auto o: objects) {
CORRADE_INTERNAL_ASSERT(o != nullptr);
references.push_back(*o);
for(auto it = objects.begin(); it != objects.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it != nullptr);
references.push_back(**it);
}
return transformations(std::move(references), initialTransformation);
@ -420,7 +421,8 @@ template<class Transformation> void Object<Transformation>::doSetClean(const std
std::vector<std::reference_wrapper<Object<Transformation>>> castObjects;
castObjects.reserve(objects.size());
/** @todo Ensure this doesn't crash, somehow */
for(auto o: objects) castObjects.push_back(static_cast<Object<Transformation>&>(o.get()));
for(auto it = objects.begin(); it != objects.end(); ++it)
castObjects.push_back(static_cast<Object<Transformation>&>(it->get()));
setClean(std::move(castObjects));
}
@ -475,9 +477,9 @@ template<class Transformation> void Object<Transformation>::setClean(std::vector
template<class Transformation> void Object<Transformation>::setClean(const std::vector<Object<Transformation>*>& objects) {
std::vector<std::reference_wrapper<Object<Transformation>>> references;
references.reserve(objects.size());
for(auto o: objects) {
CORRADE_INTERNAL_ASSERT(o != nullptr);
references.push_back(*o);
for(auto it = objects.begin(); it != objects.end(); ++it) {
CORRADE_INTERNAL_ASSERT(*it != nullptr);
references.push_back(**it);
}
setClean(std::move(references));

Loading…
Cancel
Save