summaryrefslogtreecommitdiffhomepage
path: root/serialize/packbits-read.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-01-16 09:01:36 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-01-16 09:01:36 +0100
commit30d4c8e5c26aa89a64998ef1da350d4d80359237 (patch)
treee19c909675d703dc9837202ee8ca2ced1d98a20c /serialize/packbits-read.hpp
parent07716595e0c26ba6d19ee6c498280508ca5aa6c2 (diff)
cw
Diffstat (limited to 'serialize/packbits-read.hpp')
-rw-r--r--serialize/packbits-read.hpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/serialize/packbits-read.hpp b/serialize/packbits-read.hpp
index dc21d7ee..6f5dd883 100644
--- a/serialize/packbits-read.hpp
+++ b/serialize/packbits-read.hpp
@@ -5,7 +5,7 @@
#include <utility>
#include "compat/assert.hpp"
-namespace floormat::detail_Pack_input {
+namespace floormat::Pack {
template<std::unsigned_integral T, size_t N>
struct input_bits final
@@ -114,10 +114,17 @@ constexpr void read_(Place&, input<T, Left>, std::index_sequence<Is...>, empty_p
template<std::unsigned_integral T, size_t... Ns> using make_pack = empty_pack_tuple<input_bits<T, Ns>...>;
-} // namespace floormat::detail_Pack_input
+} // namespace floormat::Pack
-namespace floormat::pack {
+namespace floormat {
+template<std::unsigned_integral T, size_t... Sizes>
+constexpr T pack_write(const std::tuple<Pack::output_field<T, Sizes>...>& tuple)
+{
+ constexpr size_t nbits = sizeof(T)*8;
+ return Pack::write_(tuple, Pack::output<T, nbits, nbits>{T{0}}, make_reverse_index_sequence<sizeof...(Sizes)>{});
+}
+constexpr uint8_t pack_write(const std::tuple<>&) = delete;
-} // namespace floormat::pack
+} // namespace floormat