From 84b8a220091e64bb1dd6c66fa49edac673df4ddb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 12 Jan 2024 21:51:38 +0100 Subject: serialize/packbits: wip --- serialize/packbits.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 serialize/packbits.cpp (limited to 'serialize/packbits.cpp') diff --git a/serialize/packbits.cpp b/serialize/packbits.cpp new file mode 100644 index 00000000..81c6c172 --- /dev/null +++ b/serialize/packbits.cpp @@ -0,0 +1,55 @@ +#include "packbits.hpp" + +namespace floormat { + +using namespace floormat::detail_Pack; + +namespace { + +constexpr bool test1() +{ + using S1 = Storage; + S1 st1{0b10111011}; + fm_assert(st1.value == 0b10111011); + + fm_assert(st1.get<3>() == 0b011); + using S2 = typename S1::next<3>; + S2 st2{st1.advance<3>()}; + static_assert(std::is_same_v>); + fm_assert(st2.value == 0b10111); + + return true; +} +static_assert(test1()); + +namespace test2 { +template using ibits = Bits_; +using foo1 = ibits<2>; +using foo2 = ibits<10>; +using foo3 = ibits<4>; +using bar1 = check_size_overflow; +static_assert(bar1::result); +static_assert(bar1::size == 12); + +using bar2 = check_size_overflow; +static_assert(bar2::result); +static_assert(bar2::size == 10); + +using bar3 = check_size_overflow; +static_assert(bar3::result); +static_assert(bar3::size == 16); + +using foo4 = ibits<1>; +using bar4 = check_size_overflow; +static_assert(!bar4::result); +static_assert(bar4::size == 17); + +using foo5 = ibits<20>; +using bar5 = check_size_overflow; +static_assert(!bar5::result); +static_assert(bar5::size == 37); +} // namespace test2 + +} // namespace + +} // namespace floormat -- cgit v1.2.3