diff --git a/src/Magnum/Math/Packing.h b/src/Magnum/Math/Packing.h index fc3df3b08..5bb75e66b 100644 --- a/src/Magnum/Math/Packing.h +++ b/src/Magnum/Math/Packing.h @@ -70,15 +70,11 @@ template inline typename std::enable_if::max()), FloatingPoint(-1.0)); } -template inline typename std::enable_if::value, FloatingPoint>::type unpack(const Integral& value) { - static_assert(std::is_floating_point::value && std::is_integral::value, - "unpacking must be done from integral to floating-point type"); - return FloatingPoint(value)/typename FloatingPoint::Type(std::numeric_limits::max()); -} -template inline typename std::enable_if::value, FloatingPoint>::type unpack(const Integral& value) { - static_assert(std::is_floating_point::value && std::is_integral::value, - "unpacking must be done from integral to floating-point type"); - return Math::max(FloatingPoint(value)/typename FloatingPoint::Type(std::numeric_limits::max()), FloatingPoint(-1.0)); +template FloatingPoint unpack(const Vector& value) { + FloatingPoint out{NoInit}; + for(std::size_t i = 0; i != size; ++i) + out[i] = unpack(value[i]); + return out; } #endif @@ -116,10 +112,11 @@ template inline typename std::enable_if::max()); } -template inline typename std::enable_if::value, Integral>::type pack(const FloatingPoint& value) { - static_assert(std::is_floating_point::value && std::is_integral::value, - "packing must be done from floating-point to integral type"); - return Integral(value*std::numeric_limits::max()); +template Integral pack(const Vector& value) { + Integral out{NoInit}; + for(std::size_t i = 0; i != size; ++i) + out[i] = pack(value[i]); + return out; } #endif