From b38c2ac1d97a2c0090ce7f63a40b98fcd174b356 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 15 Jan 2024 06:13:27 +0100 Subject: a --- serialize/packbits.cpp | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'serialize/packbits.cpp') diff --git a/serialize/packbits.cpp b/serialize/packbits.cpp index c22c621e..84d91c28 100644 --- a/serialize/packbits.cpp +++ b/serialize/packbits.cpp @@ -1,4 +1,4 @@ -#include "packbits.hpp" +#include "packbits-read.hpp" #include "compat/assert.hpp" namespace floormat { @@ -8,35 +8,34 @@ using namespace floormat::detail_Pack; namespace { template constexpr inline T lowbits = (T{1} << N)-T{1}; -template using us_bits = Bits; +template using us_bits = bits; -static_assert(!pack_input{65535}.check_zero()); -static_assert(pack_input{65535}.advance<16>() == 0); +static_assert(!input{65535}.check_zero()); +static_assert(input{65535}.advance<16>() == 0); -static_assert(pack_input::next<16>{ - pack_input{65535}.advance<16>() +static_assert(input::next<16>{ input{65535}.advance<16>() }.check_zero()); -static_assert(pack_input::next<16>{}.Capacity == 14); +static_assert(input::next<16>{}.Capacity == 14); constexpr bool test1() { constexpr size_t bits[] = { 5, 2, 1 }; constexpr size_t vals[] = { 8, 3, 1, 0 }; - constexpr auto S0 = pack_input{0b10111011}; - constexpr auto S1 = pack_input{0b00000101}; - constexpr auto S2 = pack_input{0b00000001}; - constexpr auto S3 = pack_input{0b00000000}; + constexpr auto S0 = input{0b10111011}; + constexpr auto S1 = input{0b00000101}; + constexpr auto S2 = input{0b00000001}; + constexpr auto S3 = input{0b00000000}; using P0 = std::decay_t; using P1 = P0::next; using P2 = P1::next; using P3 = P2::next; - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); - static_assert(std::is_same_v>); + static_assert(std::is_same_v>); + static_assert(std::is_same_v>); + static_assert(std::is_same_v>); + static_assert(std::is_same_v>); static_assert(S0.advance< 0>() == S0.value); static_assert(S0.advance() == S1.value); @@ -54,9 +53,9 @@ static_assert(test1()); constexpr bool test3() { - constexpr auto S0 = pack_input{0b1110100110001011}; - constexpr auto S1 = pack_input{0b1110}; - constexpr auto S2 = pack_input{0b1}; + constexpr auto S0 = input{0b1110100110001011}; + constexpr auto S1 = input{0b1110}; + constexpr auto S2 = input{0b1}; static_assert(S0.get<12>() == 0b100110001011); static_assert(S0.advance<12>() == S1.value); @@ -81,7 +80,7 @@ constexpr bool test4() { Tuple_u32 tuple{}; static_assert(lowbits == 0x1ffffU); - read_pack(tuple, pack_input{(uint32_t)-1}, std::make_index_sequence<3>{}, make_pack{}); + read(tuple, input{(uint32_t)-1}, std::make_index_sequence<3>{}, make_pack{}); auto [a, b, c] = tuple; fm_assert(a == lowbits); fm_assert(b == lowbits); @@ -89,7 +88,7 @@ constexpr bool test4() } { Tuple_u8 tuple{}; - read_pack(tuple, pack_input{0b101011}, std::make_index_sequence<3>{}, make_pack{}); + read(tuple, input{0b101011}, std::make_index_sequence<3>{}, make_pack{}); auto [a, b, c] = tuple; fm_assert(a == 0b1); fm_assert(b == 0b101); @@ -97,13 +96,13 @@ constexpr bool test4() } { std::tuple<> empty_tuple; - read_pack(empty_tuple, pack_input{0}, std::index_sequence<>{}, make_pack{}); + read(empty_tuple, input{0}, std::index_sequence<>{}, make_pack{}); Tuple_u8 tuple{}; (void)tuple; - //read_pack(empty_tuple, pack_input{1}, std::index_sequence<>{}, make_tuple{}); - //read_pack(tuple, pack_input{0b11111}, std::make_index_sequence<3>{}, make_tuple{}); - //(void)pack_input{}; - //read_pack(empty_tuple, pack_input{}, std::index_sequence<0>{}, make_tuple{}); - //read_pack(empty_tuple, pack_input{1}, std::index_sequence<>{}, make_tuple{}); + //read(empty_tuple, input{1}, std::index_sequence<>{}, make_tuple{}); + //read(tuple, input{0b11111}, std::make_index_sequence<3>{}, make_tuple{}); + //(void)input{}; + //read(empty_tuple, input{}, std::index_sequence<0>{}, make_tuple{}); + //read(empty_tuple, input{1}, std::index_sequence<>{}, make_tuple{}); } return true; -- cgit v1.2.3