From e16c243d1cab4eb236fbd08d12dbce75aac94ddf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jan 2024 11:37:10 +0100 Subject: ddd --- serialize/packbits-write.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'serialize/packbits-write.hpp') diff --git a/serialize/packbits-write.hpp b/serialize/packbits-write.hpp index 5a8eae52..ca18cfbb 100644 --- a/serialize/packbits-write.hpp +++ b/serialize/packbits-write.hpp @@ -1,12 +1,12 @@ #pragma once -#include "compat/assert.hpp" +#include "packbits-impl.hpp" #include "compat/reverse-index-sequence.hpp" #include #include #include #include -namespace floormat::Pack { +namespace floormat::Pack_impl { template struct output @@ -42,7 +42,9 @@ constexpr CORRADE_ALWAYS_INLINE T write_(const Tuple& tuple, output(tuple).value; - fm_assert((size_t)std::bit_width(x) <= N); + + if (!((size_t)std::bit_width(x) <= N)) [[unlikely]] + throw_on_write_input_bit_overflow(); T value = T(T(st.value << N) | x); return write_(tuple, output{value}, std::index_sequence{}); } @@ -53,15 +55,15 @@ constexpr CORRADE_ALWAYS_INLINE T write_(const Tuple&, output return st.value; } -} // namespace floormat::Pack +} // namespace floormat::Pack_impl namespace floormat { template -constexpr T pack_write(const std::tuple...>& tuple) +constexpr T pack_write(const std::tuple...>& tuple) { constexpr size_t nbits = sizeof(T)*8; - return Pack::write_(tuple, Pack::output{T{0}}, make_reverse_index_sequence{}); + return Pack_impl::write_(tuple, Pack_impl::output{T{0}}, make_reverse_index_sequence{}); } constexpr uint8_t pack_write(const std::tuple<>&) = delete; -- cgit v1.2.3