Browse Source

MSVC 2013 compatibility: workarounds for friend function declarations.

This is perfectly valid C++03 code, but MSVC can't cope with the <> in
it, so we need to make all templates friends, not only the
particular one. Sometimes it's internal compiler error, sometimes only
cryptic error message.
Vladimír Vondruš 13 years ago
parent
commit
51e8e546a2
  1. 5
      src/DebugTools/ShapeRenderer.h
  2. 5
      src/Shapes/AbstractShape.h
  3. 6
      src/Shapes/Composition.h

5
src/DebugTools/ShapeRenderer.h

@ -138,7 +138,12 @@ new DebugTools::ShapeRenderer2D(shape, "red", debugDrawables);
@todo Different drawing style for inverted shapes? (marking the "inside" somehow)
*/
template<UnsignedInt dimensions> class MAGNUM_DEBUGTOOLS_EXPORT ShapeRenderer: public SceneGraph::Drawable<dimensions, Float> {
/* MSVC can't cope with <> here */
#ifndef CORRADE_MSVC2013_COMPATIBILITY
friend void Implementation::createDebugMesh<>(ShapeRenderer<dimensions>&, const Shapes::Implementation::AbstractShape<dimensions>&);
#else
template<UnsignedInt dimensions_> friend void Implementation::createDebugMesh(ShapeRenderer<dimensions_>&, const Shapes::Implementation::AbstractShape<dimensions_>&);
#endif
public:
/**

5
src/Shapes/AbstractShape.h

@ -50,7 +50,12 @@ brief introduction.
@see AbstractShape2D, AbstractShape3D
*/
template<UnsignedInt dimensions> class MAGNUM_SHAPES_EXPORT AbstractShape: public SceneGraph::AbstractGroupedFeature<dimensions, AbstractShape<dimensions>, Float> {
/* MSVC can't cope with <> here */
#ifndef CORRADE_MSVC2013_COMPATIBILITY
friend const Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(const AbstractShape<dimensions>&);
#else
template<UnsignedInt dimensions_> friend const Implementation::AbstractShape<dimensions_>& Implementation::getAbstractShape(const Shapes::AbstractShape<dimensions_>&);
#endif
public:
enum: UnsignedInt {

6
src/Shapes/Composition.h

@ -64,8 +64,14 @@ enum class CompositionOperation: UnsignedByte {
Result of logical operations on shapes. See @ref shapes for brief introduction.
*/
template<UnsignedInt dimensions> class MAGNUM_SHAPES_EXPORT Composition {
/* MSVC can't cope with <> here */
#ifndef CORRADE_MSVC2013_COMPATIBILITY
friend Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(Composition<dimensions>&, std::size_t);
friend const Implementation::AbstractShape<dimensions>& Implementation::getAbstractShape<>(const Composition<dimensions>&, std::size_t);
#else
template<UnsignedInt dimensions_> friend Implementation::AbstractShape<dimensions_>& Implementation::getAbstractShape(Composition<dimensions_>&, std::size_t);
template<UnsignedInt dimensions_> friend const Implementation::AbstractShape<dimensions_>& Implementation::getAbstractShape(const Composition<dimensions_>&, std::size_t);
#endif
friend struct Implementation::ShapeHelper<Composition<dimensions>>;
public:

Loading…
Cancel
Save