From 59f69d2a4ff09aa5d4273af38d590952b58ba222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Feb 2017 22:46:56 +0100 Subject: [PATCH] Math: assert that the (un)packed vector type has the same size. --- src/Magnum/Math/Packing.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Magnum/Math/Packing.h b/src/Magnum/Math/Packing.h index e66426f2f..69c1b870e 100644 --- a/src/Magnum/Math/Packing.h +++ b/src/Magnum/Math/Packing.h @@ -94,6 +94,8 @@ template()), FloatingPoint(-1.0)); } template FloatingPoint unpack(const Vector& value) { + static_assert(FloatingPoint::Size == size, + "return vector type should have the same size as input vector type"); FloatingPoint out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = unpack(value[i]); @@ -150,6 +152,8 @@ template()); } template Integral pack(const Vector& value) { + static_assert(Integral::Size == size, + "return vector type should have the same size as input vector type"); Integral out{NoInit}; for(std::size_t i = 0; i != size; ++i) out[i] = pack(value[i]);