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-read.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'serialize/packbits-read.cpp') diff --git a/serialize/packbits-read.cpp b/serialize/packbits-read.cpp index 6b4a13d4..9980ca63 100644 --- a/serialize/packbits-read.cpp +++ b/serialize/packbits-read.cpp @@ -1,12 +1,29 @@ #include "packbits-read.hpp" #include "compat/assert.hpp" +#include "compat/exception.hpp" + +namespace floormat::Pack_impl { + +void throw_on_read_nonzero() noexcept(false) +{ + throw std::runtime_error{"extra bits in pack_read()"}; +} + +} // namespace floormat::Pack_impl namespace floormat { -using namespace floormat::Pack; +using namespace floormat::Pack_impl; namespace { +static_assert(sum<1, 2, 3, 4, 5> == 6*(6-1)/2); +static_assert(sum<5, 10, 15> == 30); + +using u32 = uint32_t; +using u16 = uint16_t; +using u8 = uint8_t; + template constexpr inline T lowbits = N == sizeof(T)*8 ? (T)-1 : (T{1} << N)-T{1}; static_assert(!input{65535}.check_zero()); -- cgit v1.2.3