From a4cdf9ca10f93181743cb75a4e3c29f23fbe84a5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 15 Jan 2024 10:31:44 +0100 Subject: w --- serialize/packbits-write.hpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'serialize/packbits-write.hpp') diff --git a/serialize/packbits-write.hpp b/serialize/packbits-write.hpp index 4217d739..060c444f 100644 --- a/serialize/packbits-write.hpp +++ b/serialize/packbits-write.hpp @@ -27,6 +27,7 @@ struct output template struct next_ { + static_assert(N <= sizeof(T)*8); static_assert(N > 0); static_assert(N <= CAPACITY); using type = output; @@ -40,7 +41,7 @@ struct output static_assert(N > 0); T value_{value}; if constexpr(CAPACITY != sizeof(T)*8) - value_ <<= CAPACITY; + value_ <<= N; auto x_ = T(x & (T{1}< -constexpr T write_(output st, output_field field, Fields... fields) +template struct count_bits; + + +template struct count_bits, Ts...>> +{ + static constexpr size_t length = N + count_bits>::length; + static_assert(length <= sizeof(T)*8); +}; + +template struct count_bits> +{ + static constexpr size_t length = 0; +}; + +#if 0 +template +constexpr T write_(output st, std::tuple> fields) { - T value = st.set(field.value, output_bits{}); + T value0 = fields.get< std::tuple_size_v>>-1 >(fields).value; + T value = st.set(value0, output_bits{}); using next = typename output::template next; - return write_(next{value}, fields...); + return write_(next{value}, ); } template @@ -68,5 +85,6 @@ constexpr T write_(output st) { return st.value; } +#endif } // namespace floormat::detail_Pack_output -- cgit v1.2.3