Browse Source

Math: hardened checks for proper size of primitive types.

pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
33653a3469
  1. 40
      src/Math/instantiation.cpp

40
src/Math/instantiation.cpp

@ -105,6 +105,46 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quate
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion<Double>&);
#endif
/* Check proper size of GL types */
static_assert(sizeof(Vector<2, Float>) == 8, "Improper size of 2-element Float vector");
static_assert(sizeof(Vector<3, Float>) == 12, "Improper size of 3-element Float vector");
static_assert(sizeof(Vector<4, Float>) == 16, "Improper size of 4-element Float vector");
static_assert(sizeof(Vector<2, Int>) == 8, "Improper size of 2-element Int vector");
static_assert(sizeof(Vector<3, Int>) == 12, "Improper size of 3-element Int vector");
static_assert(sizeof(Vector<4, Int>) == 16, "Improper size of 4-element Int vector");
static_assert(sizeof(Vector<2, UnsignedInt>) == 8, "Improper size of 2-element UnsignedInt vector");
static_assert(sizeof(Vector<3, UnsignedInt>) == 12, "Improper size of 3-element UnsignedInt vector");
static_assert(sizeof(Vector<4, UnsignedInt>) == 16, "Improper size of 4-element UnsignedInt vector");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(Vector<2, Double>) == 16, "Improper size of 2-element Double vector");
static_assert(sizeof(Vector<3, Double>) == 24, "Improper size of 3-element Double vector");
static_assert(sizeof(Vector<4, Double>) == 32, "Improper size of 4-element Double vector");
#endif
static_assert(sizeof(RectangularMatrix<2, 2, Float>) == 16, "Improper size of 2x2 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 3, Float>) == 36, "Improper size of 3x3 Float matrix");
static_assert(sizeof(RectangularMatrix<4, 4, Float>) == 64, "Improper size of 4x4 Float matrix");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(RectangularMatrix<2, 2, Double>) == 32, "Improper size of 2x2 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 3, Double>) == 72, "Improper size of 3x3 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 4, Double>) == 128, "Improper size of 4x4 Double matrix");
#endif
static_assert(sizeof(RectangularMatrix<2, 3, Float>) == 24, "Improper size of 2x3 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 2, Float>) == 24, "Improper size of 3x2 Float matrix");
static_assert(sizeof(RectangularMatrix<2, 4, Float>) == 32, "Improper size of 2x4 Float matrix");
static_assert(sizeof(RectangularMatrix<4, 2, Float>) == 32, "Improper size of 4x2 Float matrix");
static_assert(sizeof(RectangularMatrix<3, 4, Float>) == 48, "Improper size of 3x4 Float matrix");
static_assert(sizeof(RectangularMatrix<4, 3, Float>) == 48, "Improper size of 4x3 Float matrix");
#ifndef MAGNUM_TARGET_GLES
static_assert(sizeof(RectangularMatrix<2, 3, Double>) == 48, "Improper size of 2x3 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 2, Double>) == 48, "Improper size of 3x2 Double matrix");
static_assert(sizeof(RectangularMatrix<2, 4, Double>) == 64, "Improper size of 2x4 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 2, Double>) == 64, "Improper size of 4x2 Double matrix");
static_assert(sizeof(RectangularMatrix<3, 4, Double>) == 96, "Improper size of 3x4 Double matrix");
static_assert(sizeof(RectangularMatrix<4, 3, Double>) == 96, "Improper size of 4x3 Double matrix");
#endif
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 2, Float>&);
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 3, Float>&);
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 4, Float>&);

Loading…
Cancel
Save