From b8f7747d79cbe41b75c5e2fa63f600954be07092 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 13 Jan 2024 09:28:44 +0100 Subject: a --- serialize/packbits.cpp | 10 ++++++---- serialize/packbits.hpp | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/serialize/packbits.cpp b/serialize/packbits.cpp index 8a5d376b..67820649 100644 --- a/serialize/packbits.cpp +++ b/serialize/packbits.cpp @@ -12,10 +12,10 @@ constexpr bool test1() constexpr size_t bits[] = { 5, 2, 1, 0 }; constexpr size_t vals[] = { 8, 3, 1, 0 }; - constexpr auto S0 = Storage{0b10111011}; - constexpr auto S1 = Storage{0b00000101}; - constexpr auto S2 = Storage{0b00000001}; - constexpr auto S3 = Storage{0b00000000}; + constexpr auto S0 = Storage{0b10111011}; + constexpr auto S1 = Storage{0b00000101}; + constexpr auto S2 = Storage{0b00000001}; + constexpr auto S3 = Storage{0b00000000}; using P0 = std::decay_t; using P1 = P0::next; @@ -28,6 +28,7 @@ constexpr bool test1() static_assert(std::is_same_v>); static_assert(std::is_same_v>); + static_assert(S0.advance<0>() == S0.value); static_assert(S0.advance<5>() == S1.value); static_assert(S1.advance<2>() == S2.value); static_assert(S2.advance<1>() == S3.value); @@ -35,6 +36,7 @@ constexpr bool test1() static_assert(S0.get() == (S0.value & (1<() == (S1.value & (1<() == (S2.value & (1< constexpr T get() const { + static_assert(N > 0); static_assert(N <= sizeof(T)*8); static_assert(N <= Capacity); return T(value & (T(1) << N) - T(1)); -- cgit v1.2.3