From 9b957f519620a07597fa28f796c09bdbef2e8fab Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 Jan 2024 14:55:25 +0100 Subject: aa --- serialize/packbits.hpp | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'serialize/packbits.hpp') diff --git a/serialize/packbits.hpp b/serialize/packbits.hpp index cb91602f..12c1dd31 100644 --- a/serialize/packbits.hpp +++ b/serialize/packbits.hpp @@ -1,6 +1,8 @@ #pragma once #include #include +#include +#include "compat/assert.hpp" namespace floormat::Pack { template struct Bits_; @@ -55,7 +57,7 @@ struct Storage } constexpr bool operator==(const Storage&) const noexcept = default; - constexpr bool check_zero() const = delete; + [[nodiscard]] constexpr inline bool check_zero() const { return value == T(0); } template using next = Storage; }; @@ -70,11 +72,7 @@ struct Storage template [[maybe_unused]] constexpr T get() const = delete; template [[maybe_unused]] constexpr T advance() const = delete; constexpr bool operator==(const Storage&) const noexcept = default; - - [[nodiscard]] constexpr inline bool check_zero() const - { - return value == T(0); - } + [[nodiscard]] constexpr inline bool check_zero() const { return true; } template struct next { @@ -83,6 +81,34 @@ struct Storage }; }; +template +struct make_tuple_type_ +{ + template using index_to_type = T; + template struct aux; + template struct aux> + { + static_assert(sizeof...(Is) > 0); + using type = std::tuple...>; + }; + using Seq = typename aux>::type; +}; +template using make_tuple_type = typename make_tuple_type_::Seq; + +template +static void assign_to_tuple(Place&, Storage st, std::index_sequence<>) +{ + fm_assert(st.check_zero()); +} + +template +static void assign_to_tuple(Place& p, Storage st, std::index_sequence) +{ + using std::get; + get(p) = st.template get(st); + assign_to_tuple(p, st.template advance(), std::index_sequence{}); +} + } // namespace floormat::detail_Pack namespace floormat::Pack { -- cgit v1.2.3