From 0557add6e5e7378708dbabc2d94b1b1d34603c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 12 Oct 2018 19:52:36 +0200 Subject: [PATCH] SceneGraph: properly forward references in addChild()/addFeature(). --- doc/changelog.dox | 3 +++ src/Magnum/SceneGraph/AbstractObject.h | 2 +- src/Magnum/SceneGraph/Object.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/changelog.dox b/doc/changelog.dox index 5e5ffe45e..d2b4502b9 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -404,6 +404,9 @@ See also: - Improved @ref TextureTools::distanceField() to work better on shader compilers that have problems compiling nested loops (WebGL implementations, some ES2 devices) +- @ref SceneGraph::AbstractObject::addFeature() and + @ref SceneGraph::Object::addChild() were not properly forwarding reference + arguments @subsection changelog-latest-docs Documentation diff --git a/src/Magnum/SceneGraph/AbstractObject.h b/src/Magnum/SceneGraph/AbstractObject.h index dafa4d2af..cf8c83052 100644 --- a/src/Magnum/SceneGraph/AbstractObject.h +++ b/src/Magnum/SceneGraph/AbstractObject.h @@ -111,7 +111,7 @@ template class AbstractObject * Calling `object.addFeature(args...)` is equivalent to * `new MyFeature{object, args...}`. */ - template U& addFeature(Args... args) { + template U& addFeature(Args&&... args) { return *(new U{*this, std::forward(args)...}); } diff --git a/src/Magnum/SceneGraph/Object.h b/src/Magnum/SceneGraph/Object.h index 63f8b85ef..3c122138d 100644 --- a/src/Magnum/SceneGraph/Object.h +++ b/src/Magnum/SceneGraph/Object.h @@ -193,7 +193,7 @@ template class Object: public AbstractObject(args...)` is equivalent to * `new MyObject{args..., &object}`. */ - template T& addChild(Args... args) { + template T& addChild(Args&&... args) { return *(new T{std::forward(args)..., this}); }