Browse Source

Math: clearly document what the TypeForSize helper is for.

I was initially not sure if it has some other use than the swizzle APIs.
It doesn't, so mention that clearly.
pull/686/head
Vladimír Vondruš 4 months ago
parent
commit
f68e277a41
  1. 1
      src/Magnum/Math/Color.h
  2. 3
      src/Magnum/Math/Swizzle.h
  3. 1
      src/Magnum/Math/Vector2.h
  4. 1
      src/Magnum/Math/Vector3.h
  5. 1
      src/Magnum/Math/Vector4.h

1
src/Magnum/Math/Color.h

@ -1942,6 +1942,7 @@ MAGNUM_EXPORT Debug& operator<<(Debug& debug, const Color4<UnsignedByte>& value)
#endif #endif
namespace Implementation { namespace Implementation {
/* Used by Swizzle.h */
template<class T> struct TypeForSize<3, Color3<T>> { typedef Color3<T> Type; }; template<class T> struct TypeForSize<3, Color3<T>> { typedef Color3<T> Type; };
template<class T> struct TypeForSize<3, Color4<T>> { typedef Color3<T> Type; }; template<class T> struct TypeForSize<3, Color4<T>> { typedef Color3<T> Type; };
template<class T> struct TypeForSize<4, Color3<T>> { typedef Color4<T> Type; }; template<class T> struct TypeForSize<4, Color3<T>> { typedef Color4<T> Type; };

3
src/Magnum/Math/Swizzle.h

@ -59,6 +59,9 @@ namespace Implementation {
template<class T> constexpr static T value(const Math::Vector<size, T>&) { return T(1); } template<class T> constexpr static T value(const Math::Vector<size, T>&) { return T(1); }
}; };
/* Additional specializations in Vector2.h, Vector3.h, Vector4.h and
Color.h. That way it's possible to return a concrete Vector subtype
without having to include it directly from here. */
template<std::size_t size, class T> struct TypeForSize { template<std::size_t size, class T> struct TypeForSize {
typedef Math::Vector<size, typename T::Type> Type; typedef Math::Vector<size, typename T::Type> Type;
}; };

1
src/Magnum/Math/Vector2.h

@ -250,6 +250,7 @@ _MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION(2, Vector2)
#endif #endif
namespace Implementation { namespace Implementation {
/* Used by Swizzle.h */
template<std::size_t, class> struct TypeForSize; template<std::size_t, class> struct TypeForSize;
template<class T> struct TypeForSize<2, T> { typedef Math::Vector2<typename T::Type> Type; }; template<class T> struct TypeForSize<2, T> { typedef Math::Vector2<typename T::Type> Type; };
#ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING #ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING

1
src/Magnum/Math/Vector3.h

@ -288,6 +288,7 @@ _MAGNUM_VECTORn_OPERATOR_IMPLEMENTATION(3, Vector3)
#endif #endif
namespace Implementation { namespace Implementation {
/* Used by Swizzle.h */
template<class T> struct TypeForSize<3, T> { typedef Math::Vector3<typename T::Type> Type; }; template<class T> struct TypeForSize<3, T> { typedef Math::Vector3<typename T::Type> Type; };
#ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING #ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING
template<class T> struct StrictWeakOrdering<Vector3<T>>: StrictWeakOrdering<Vector<3, T>> {}; template<class T> struct StrictWeakOrdering<Vector3<T>>: StrictWeakOrdering<Vector<3, T>> {};

1
src/Magnum/Math/Vector4.h

@ -315,6 +315,7 @@ template<class T> Vector4<T> planeEquation(const Vector3<T>& normal, const Vecto
} }
namespace Implementation { namespace Implementation {
/* Used by Swizzle.h */
template<class T> struct TypeForSize<4, T> { typedef Math::Vector4<typename T::Type> Type; }; template<class T> struct TypeForSize<4, T> { typedef Math::Vector4<typename T::Type> Type; };
#ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING #ifndef MAGNUM_NO_MATH_STRICT_WEAK_ORDERING
template<class T> struct StrictWeakOrdering<Vector4<T>>: StrictWeakOrdering<Vector<4, T>> {}; template<class T> struct StrictWeakOrdering<Vector4<T>>: StrictWeakOrdering<Vector<4, T>> {};

Loading…
Cancel
Save