diff --git a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp index 2e5675ec4..8e3950053 100644 --- a/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp +++ b/src/Magnum/MeshTools/Test/CombineIndexedArraysTest.cpp @@ -52,7 +52,8 @@ void CombineIndexedArraysTest::wrongIndexCount() { Error::setOutput(&ss); std::vector a{0, 1, 0}; std::vector b{3, 4}; - std::vector result = MeshTools::combineIndexArrays({a, b}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + MeshTools::combineIndexArrays({std::ref(a), std::ref(b)}); CORRADE_COMPARE(ss.str(), "MeshTools::combineIndexArrays(): the arrays don't have the same size\n"); } @@ -62,7 +63,8 @@ void CombineIndexedArraysTest::indexArrays() { std::vector b{3, 4, 3}; std::vector c{6, 7, 6}; - std::vector result = MeshTools::combineIndexArrays({a, b, c}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + std::vector result = MeshTools::combineIndexArrays({std::ref(a), std::ref(b), std::ref(c)}); CORRADE_COMPARE(result, (std::vector{0, 1, 0})); CORRADE_COMPARE(a, (std::vector{0, 1})); CORRADE_COMPARE(b, (std::vector{3, 4})); diff --git a/src/Magnum/SceneGraph/AbstractCamera.hpp b/src/Magnum/SceneGraph/AbstractCamera.hpp index e1b72b520..6987390de 100644 --- a/src/Magnum/SceneGraph/AbstractCamera.hpp +++ b/src/Magnum/SceneGraph/AbstractCamera.hpp @@ -97,7 +97,8 @@ template void AbstractCamera::dr std::vector>> objects; objects.reserve(group.size()); for(std::size_t i = 0; i != group.size(); ++i) - objects.push_back(group[i].object()); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + objects.push_back(std::ref(group[i].object())); std::vector::MatrixType> transformations = scene->transformationMatrices(objects, _cameraMatrix); diff --git a/src/Magnum/SceneGraph/FeatureGroup.hpp b/src/Magnum/SceneGraph/FeatureGroup.hpp index b09afd2d2..2340ce5aa 100644 --- a/src/Magnum/SceneGraph/FeatureGroup.hpp +++ b/src/Magnum/SceneGraph/FeatureGroup.hpp @@ -42,7 +42,8 @@ template AbstractFeatureGroup::A template AbstractFeatureGroup::~AbstractFeatureGroup() {} template void AbstractFeatureGroup::add(AbstractFeature& feature) { - features.push_back(feature); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + features.push_back(std::ref(feature)); } template void AbstractFeatureGroup::remove(AbstractFeature& feature) { diff --git a/src/Magnum/SceneGraph/Object.hpp b/src/Magnum/SceneGraph/Object.hpp index 830d34d06..150175efa 100644 --- a/src/Magnum/SceneGraph/Object.hpp +++ b/src/Magnum/SceneGraph/Object.hpp @@ -44,7 +44,8 @@ template void AbstractObject::se references.reserve(objects.size()); for(auto it = objects.begin(); it != objects.end(); ++it) { CORRADE_INTERNAL_ASSERT(*it != nullptr); - references.push_back(**it); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + references.push_back(std::ref(**it)); } setClean(references); @@ -67,7 +68,8 @@ template auto AbstractObject::tr references.reserve(objects.size()); for(auto it = objects.begin(); it != objects.end(); ++it) { CORRADE_INTERNAL_ASSERT(*it != nullptr); - references.push_back(**it); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + references.push_back(std::ref(**it)); } return transformationMatrices(references, initialTransformationMatrix); @@ -210,7 +212,8 @@ template auto Object::doTransformationMatr castObjects.reserve(objects.size()); /** @todo Ensure this doesn't crash, somehow */ for(auto it = objects.begin(); it != objects.end(); ++it) - castObjects.push_back(static_cast&>(it->get())); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + castObjects.push_back(std::ref(static_cast&>(it->get()))); return transformationMatrices(std::move(castObjects), initialTransformationMatrix); } @@ -230,7 +233,8 @@ template auto Object::transformationMatric references.reserve(objects.size()); for(auto it = objects.begin(); it != objects.end(); ++it) { CORRADE_INTERNAL_ASSERT(*it != nullptr); - references.push_back(**it); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + references.push_back(std::ref(**it)); } return transformationMatrices(references, initialTransformationMatrix); @@ -313,11 +317,13 @@ template std::vector Ob CORRADE_INTERNAL_ASSERT(parent->counter == 0xFFFFu); parent->counter = UnsignedShort(jointObjects.size()); parent->flags |= Flag::Joint; - jointObjects.push_back(*parent); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + jointObjects.push_back(std::ref(*parent)); } /* Else go up the hierarchy */ - } else *it = *parent; + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + } else *it = std::ref(*parent); /* Cycle if reached end */ if(it == objects.end()) it = objects.begin(); @@ -364,7 +370,8 @@ template std::vector Ob references.reserve(objects.size()); for(auto it = objects.begin(); it != objects.end(); ++it) { CORRADE_INTERNAL_ASSERT(*it != nullptr); - references.push_back(**it); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + references.push_back(std::ref(**it)); } return transformations(std::move(references), initialTransformation); @@ -416,7 +423,8 @@ template typename Transformation::DataType Object::compose(parent->transformation(), jointTransformations[joint]); - o = *parent; + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + o = std::ref(*parent); } } } @@ -426,7 +434,8 @@ template void Object::doSetClean(const std castObjects.reserve(objects.size()); /** @todo Ensure this doesn't crash, somehow */ for(auto it = objects.begin(); it != objects.end(); ++it) - castObjects.push_back(static_cast&>(it->get())); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + castObjects.push_back(std::ref(static_cast&>(it->get()))); setClean(std::move(castObjects)); } @@ -447,7 +456,8 @@ template void Object::setClean(std::vector Object* parent = o.parent(); while(parent && !(parent->flags & Flag::Visited) && parent->isDirty()) { - objects.push_back(*parent); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + objects.push_back(std::ref(*parent)); parent = parent->parent(); } } @@ -483,7 +493,8 @@ template void Object::setClean(const std:: references.reserve(objects.size()); for(auto it = objects.begin(); it != objects.end(); ++it) { CORRADE_INTERNAL_ASSERT(*it != nullptr); - references.push_back(**it); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + references.push_back(std::ref(**it)); } setClean(std::move(references)); diff --git a/src/Magnum/SceneGraph/Test/ObjectTest.cpp b/src/Magnum/SceneGraph/Test/ObjectTest.cpp index 5139c4b12..e585dd47a 100644 --- a/src/Magnum/SceneGraph/Test/ObjectTest.cpp +++ b/src/Magnum/SceneGraph/Test/ObjectTest.cpp @@ -181,19 +181,22 @@ void ObjectTest::transformations() { #endif /* Scene alone */ - CORRADE_COMPARE(s.transformations({s}, initial), std::vector{initial}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::reference_wrapper(s)}, initial), std::vector{initial}); /* One object */ Object3D first(&s); first.rotateZ(Deg(30.0f)); Object3D second(&first); second.scale(Vector3(0.5f)); - CORRADE_COMPARE(s.transformations({second}, initial), std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(second)}, initial), std::vector{ initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)) }); /* One object and scene */ - CORRADE_COMPARE(s.transformations({second, s}, initial), (std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(second), std::reference_wrapper(s)}, initial), (std::vector{ initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial })); @@ -201,13 +204,15 @@ void ObjectTest::transformations() { /* Two objects with foreign joint */ Object3D third(&first); third.translate(Vector3::xAxis(5.0f)); - CORRADE_COMPARE(s.transformations({second, third}, initial), (std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(second), std::ref(third)}, initial), (std::vector{ initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), })); /* Three objects with joint as one of them */ - CORRADE_COMPARE(s.transformations({second, third, first}, initial), (std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(second), std::ref(third), std::ref(first)}, initial), (std::vector{ initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), initial*Matrix4::rotationZ(Deg(30.0f)), @@ -226,7 +231,8 @@ void ObjectTest::transformationsRelative() { third.translate(Vector3::xAxis(5.0f)); /* Transformation relative to another object */ - CORRADE_COMPARE(second.transformations({third}), std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(second.transformations({std::ref(third)}), std::vector{ Matrix4::scaling(Vector3(0.5f)).inverted()*Matrix4::translation(Vector3::xAxis(5.0f)) }); @@ -238,7 +244,8 @@ void ObjectTest::transformationsRelative() { orphan1.scale(Vector3::xScale(3.0f)); Object3D orphan2(&orphanParent); orphan2.translate(Vector3::zAxis(5.0f)); - CORRADE_COMPARE(orphan1.transformations({orphan2}), std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(orphan1.transformations({std::ref(orphan2)}), std::vector{ Matrix4::scaling(Vector3::xScale(3.0f)).inverted()*Matrix4::translation(Vector3::zAxis(5.0f)) }); } @@ -250,7 +257,8 @@ void ObjectTest::transformationsOrphan() { /* Transformation of objects not part of the same scene */ Scene3D s; Object3D orphan; - CORRADE_COMPARE(s.transformations({orphan}), std::vector()); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(orphan)}), std::vector()); CORRADE_COMPARE(o.str(), "SceneGraph::Object::transformations(): the objects are not part of the same tree\n"); } @@ -266,7 +274,8 @@ void ObjectTest::transformationsDuplicate() { Matrix4 firstExpected = Matrix4::rotationZ(Deg(30.0f)); Matrix4 secondExpected = Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)); Matrix4 thirdExpected = Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)); - CORRADE_COMPARE(s.transformations({second, third, second, first, third}), (std::vector{ + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + CORRADE_COMPARE(s.transformations({std::ref(second), std::ref(third), std::ref(second), std::ref(first), std::ref(third)}), (std::vector{ secondExpected, thirdExpected, secondExpected, firstExpected, thirdExpected })); } @@ -396,7 +405,8 @@ void ObjectTest::setCleanListHierarchy() { childThree->rotate(Deg(90.0f), Vector3::yAxis()); /* Clean the object and all its dirty parents (but not children) */ - Scene3D::setClean({*childTwo}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + Scene3D::setClean({std::reference_wrapper(*childTwo)}); CORRADE_VERIFY(!scene.isDirty()); CORRADE_VERIFY(!childOne->isDirty()); CORRADE_VERIFY(!childTwo->isDirty()); @@ -410,13 +420,15 @@ void ObjectTest::setCleanListHierarchy() { /* If the object itself is already clean, it shouldn't clean it again */ childOne->cleanedAbsoluteTransformation = Matrix4(Matrix4::Zero); CORRADE_VERIFY(!childOne->isDirty()); - Scene3D::setClean({*childOne}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + Scene3D::setClean({std::reference_wrapper(*childOne)}); CORRADE_COMPARE(childOne->cleanedAbsoluteTransformation, Matrix4(Matrix4::Zero)); /* If any object in the hierarchy is already clean, it shouldn't clean it again */ CORRADE_VERIFY(!childOne->isDirty()); childTwo->setDirty(); - Scene3D::setClean({*childTwo}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + Scene3D::setClean({std::reference_wrapper(*childTwo)}); CORRADE_COMPARE(childOne->cleanedAbsoluteTransformation, Matrix4(Matrix4::Zero)); } @@ -444,7 +456,8 @@ void ObjectTest::setCleanListBulk() { CORRADE_VERIFY(c.isDirty()); CORRADE_VERIFY(d.isDirty()); CORRADE_VERIFY(e.isDirty()); - Object3D::setClean({a, b, c, d, e}); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + Object3D::setClean({std::ref(a), std::ref(b), std::ref(c), std::reference_wrapper(d), std::ref(e)}); CORRADE_VERIFY(!a.isDirty()); CORRADE_VERIFY(!b.isDirty()); CORRADE_VERIFY(!c.isDirty()); diff --git a/src/Magnum/Shapes/ShapeGroup.cpp b/src/Magnum/Shapes/ShapeGroup.cpp index aebee420d..dfe87a2d2 100644 --- a/src/Magnum/Shapes/ShapeGroup.cpp +++ b/src/Magnum/Shapes/ShapeGroup.cpp @@ -35,7 +35,8 @@ template void ShapeGroup::setClean() { std::vector>> objects; objects.reserve(this->size()); for(std::size_t i = 0; i != this->size(); ++i) - objects.push_back((*this)[i].object()); + /* GCC 4.4 has explicit constructor for std::reference_wrapper. WHY ON EARTH. WHY. */ + objects.push_back(std::ref((*this)[i].object())); SceneGraph::AbstractObject::setClean(objects); }