Browse Source

SceneGraph: workaround ambiguous overloads on deprecated GCC < 4.7 build.

GCC 4.7 cannot detect proper overload based on arguments in initializer
list constructor of some type, thus we need to provide explicit overload
taking std::initializer_lists.
pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
ceb150f6d6
  1. 18
      src/Magnum/SceneGraph/AbstractObject.h
  2. 27
      src/Magnum/SceneGraph/Object.h
  3. 30
      src/Magnum/SceneGraph/Object.hpp

18
src/Magnum/SceneGraph/AbstractObject.h

@ -165,6 +165,15 @@ template<UnsignedInt dimensions, class T> class AbstractObject
* @deprecated Use @ref Magnum::SceneGraph::AbstractObject::transformationMatrices(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&, const MatrixType&) "transformationMatrices(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&, const MatrixType&)" instead.
*/
CORRADE_DEPRECATED("use transformationMatrices(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&, const MatrixType&) instead") std::vector<MatrixType> transformationMatrices(const std::vector<AbstractObject<dimensions, T>*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const;
#ifdef CORRADE_GCC47_COMPATIBILITY
/* Workarounds to avoid ambiguous overload errors on GCC < 4.8. And I
thought 4.7 was bug-free. */
std::vector<MatrixType> transformationMatrices(std::initializer_list<std::reference_wrapper<AbstractObject<dimensions, T>>>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) {
return transformationMatrices(std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>{objects}, initialTransformationMatrix);
}
CORRADE_DEPRECATED("use transformationMatrices(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&, const MatrixType&) instead") std::vector<MatrixType> transformationMatrices(std::initializer_list<AbstractObject<dimensions, T>*> objects, const MatrixType& initialTransformationMatrix = MatrixType()) const;
#endif
#endif
/*@}*/
@ -194,6 +203,15 @@ template<UnsignedInt dimensions, class T> class AbstractObject
* @deprecated Use @ref Magnum::SceneGraph::AbstractObject::setClean(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&) "setClean(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&)" instead.
*/
static CORRADE_DEPRECATED("use setClean(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&) instead") void setClean(const std::vector<AbstractObject<dimensions, T>*>& objects);
#ifdef CORRADE_GCC47_COMPATIBILITY
/* Workarounds to avoid ambiguous overload errors on GCC < 4.8. And I
thought 4.7 was bug-free. */
static void setClean(std::initializer_list<std::reference_wrapper<AbstractObject<dimensions, T>>> objects) {
return setClean(std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>{objects});
}
static CORRADE_DEPRECATED("use setClean(const std::vector<std::reference_wrapper<AbstractObject<dimensions, T>>>&) instead") void setClean(std::initializer_list<AbstractObject<dimensions, T>*> objects);
#endif
#endif
/**

27
src/Magnum/SceneGraph/Object.h

@ -257,6 +257,15 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
* @deprecated Use @ref Magnum::SceneGraph::Object::transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>&, const MatrixType&) "transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>&, const MatrixType&)" instead.
*/
CORRADE_DEPRECATED("use transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>&, const MatrixType&) instead") std::vector<MatrixType> transformationMatrices(const std::vector<Object<Transformation>*>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const;
#ifdef CORRADE_GCC47_COMPATIBILITY
/* Workarounds to avoid ambiguous overload errors on GCC < 4.8. And I
thought 4.7 was bug-free. */
std::vector<MatrixType> transformationMatrices(std::initializer_list<std::reference_wrapper<Object<Transformation>>> objects, const MatrixType& initialTransformationMatrix = MatrixType()) const {
return transformationMatrices(std::vector<std::reference_wrapper<Object<Transformation>>>{objects}, initialTransformationMatrix);
}
CORRADE_DEPRECATED("use transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>&, const MatrixType&) instead") std::vector<MatrixType> transformationMatrices(std::initializer_list<Object<Transformation>*> objects, const MatrixType& initialTransformationMatrix = MatrixType()) const;
#endif
#endif
/**
@ -276,6 +285,15 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
* @deprecated Use @ref Magnum::SceneGraph::Object::transformations(std::vector<std::reference_wrapper<Object<Transformation>>>, const typename Transformation::DataType&) "transformations(std::vector<std::reference_wrapper<Object<Transformation>>>, const typename Transformation::DataType&)" instead.
*/
CORRADE_DEPRECATED("use transformations(std::vector<std::reference_wrapper<Object<Transformation>>>, const typename Transformation::DataType&) instead") std::vector<typename Transformation::DataType> transformations(std::vector<Object<Transformation>*> objects, const typename Transformation::DataType& initialTransformation = typename Transformation::DataType()) const;
#ifdef CORRADE_GCC47_COMPATIBILITY
/* Workarounds to avoid ambiguous overload errors on GCC < 4.8. And I
thought 4.7 was bug-free. */
std::vector<typename Transformation::DataType> transformations(std::initializer_list<std::reference_wrapper<Object<Transformation>>> objects, const typename Transformation::DataType& initialTransformation = typename Transformation::DataType()) const {
return transformations(std::vector<std::reference_wrapper<Object<Transformation>>>{objects}, initialTransformation);
}
CORRADE_DEPRECATED("use transformations(std::vector<std::reference_wrapper<Object<Transformation>>>, const typename Transformation::DataType&) instead") std::vector<typename Transformation::DataType> transformations(std::initializer_list<Object<Transformation>*> objects, const typename Transformation::DataType& initialTransformation = typename Transformation::DataType()) const;
#endif
#endif
/*@}*/
@ -301,6 +319,15 @@ template<class Transformation> class Object: public AbstractObject<Transformatio
* @deprecated Use @ref Magnum::SceneGraph::Object::setClean(std::vector<std::reference_wrapper<Object<Transformation>>> "setClean(std::vector<std::reference_wrapper<Object<Transformation>>>" instead.
*/
CORRADE_DEPRECATED("use setClean(std::vector<std::reference_wrapper<Object<Transformation>>>) instead") static void setClean(std::vector<Object<Transformation>*> objects);
#ifdef CORRADE_GCC47_COMPATIBILITY
/* Workarounds to avoid ambiguous overload errors on GCC < 4.8. And I
thought 4.7 was bug-free. */
static void setClean(std::initializer_list<std::reference_wrapper<Object<Transformation>>> objects) {
setClean(std::vector<std::reference_wrapper<Object<Transformation>>>{objects});
}
static CORRADE_DEPRECATED("use setClean(std::vector<std::reference_wrapper<Object<Transformation>>>) instead") void setClean(std::initializer_list<Object<Transformation>*> objects);
#endif
#endif
/** @copydoc AbstractObject::isDirty() */

30
src/Magnum/SceneGraph/Object.hpp

@ -49,6 +49,12 @@ template<UnsignedInt dimensions, class T> void AbstractObject<dimensions, T>::se
setClean(references);
}
#ifdef CORRADE_GCC47_COMPATIBILITY
template<UnsignedInt dimensions, class T> void AbstractObject<dimensions, T>::setClean(std::initializer_list<AbstractObject<dimensions, T>*> objects) {
return setClean(std::vector<AbstractObject<dimensions, T>*>{objects});
}
#endif
#endif
template<UnsignedInt dimensions, class T> AbstractObject<dimensions, T>::AbstractObject() {}
@ -65,6 +71,12 @@ template<UnsignedInt dimensions, class T> auto AbstractObject<dimensions, T>::tr
return transformationMatrices(references, initialTransformationMatrix);
}
#ifdef CORRADE_GCC47_COMPATIBILITY
template<UnsignedInt dimensions, class T> auto AbstractObject<dimensions, T>::transformationMatrices(std::initializer_list<AbstractObject<dimensions, T>*> objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> {
return transformationMatrices(std::vector<AbstractObject<dimensions, T>*>{objects}, initialTransformationMatrix);
}
#endif
#endif
template<UnsignedInt dimensions, class T> AbstractTransformation<dimensions, T>::AbstractTransformation() {}
@ -219,6 +231,12 @@ template<class Transformation> auto Object<Transformation>::transformationMatric
return transformationMatrices(references, initialTransformationMatrix);
}
#ifdef CORRADE_GCC47_COMPATIBILITY
template<class Transformation> auto Object<Transformation>::transformationMatrices(std::initializer_list<Object<Transformation>*> objects, const MatrixType& initialTransformationMatrix) const -> std::vector<MatrixType> {
return transformationMatrices(std::vector<Object<Transformation>*>{objects}, initialTransformationMatrix);
}
#endif
#endif
/*
@ -339,6 +357,12 @@ template<class Transformation> std::vector<typename Transformation::DataType> Ob
return transformations(references, initialTransformation);
}
#ifdef CORRADE_GCC47_COMPATIBILITY
template<class Transformation> std::vector<typename Transformation::DataType> Object<Transformation>::transformations(std::initializer_list<Object<Transformation>*> objects, const typename Transformation::DataType& initialTransformation) const {
return transformations(std::vector<Object<Transformation>*>{objects}, initialTransformation);
}
#endif
#endif
template<class Transformation> typename Transformation::DataType Object<Transformation>::computeJointTransformation(const std::vector<std::reference_wrapper<Object<Transformation>>>& jointObjects, std::vector<typename Transformation::DataType>& jointTransformations, const std::size_t joint, const typename Transformation::DataType& initialTransformation) const {
@ -437,6 +461,12 @@ template<class Transformation> void Object<Transformation>::setClean(std::vector
return setClean(references);
}
#ifdef CORRADE_GCC47_COMPATIBILITY
template<class Transformation> void Object<Transformation>::setClean(std::initializer_list<Object<Transformation>*> objects) {
setClean(std::vector<Object<Transformation>*>{objects});
}
#endif
#endif
template<class Transformation> void Object<Transformation>::setCleanInternal(const typename Transformation::DataType& absoluteTransformation) {

Loading…
Cancel
Save