summaryrefslogtreecommitdiffhomepage
path: root/serialize
diff options
context:
space:
mode:
Diffstat (limited to 'serialize')
-rw-r--r--serialize/packbits-impl.cpp5
-rw-r--r--serialize/packbits-read.hpp6
-rw-r--r--serialize/packbits-write.cpp7
-rw-r--r--serialize/packbits-write.hpp2
4 files changed, 18 insertions, 2 deletions
diff --git a/serialize/packbits-impl.cpp b/serialize/packbits-impl.cpp
index b7a4eefc..b03b31b6 100644
--- a/serialize/packbits-impl.cpp
+++ b/serialize/packbits-impl.cpp
@@ -8,4 +8,9 @@ void throw_on_read_nonzero() noexcept(false)
throw std::runtime_error{"extra bits in pack_read()"};
}
+void throw_on_write_input_bit_overflow() noexcept(false)
+{
+ throw std::runtime_error{"extra bits in pack_write()"};
+}
+
} // namespace floormat::Pack_impl
diff --git a/serialize/packbits-read.hpp b/serialize/packbits-read.hpp
index 0fea0ba5..d2622d49 100644
--- a/serialize/packbits-read.hpp
+++ b/serialize/packbits-read.hpp
@@ -84,7 +84,7 @@ requires requires (Field& x)
{
{ size_t{Field::Length} > 0 };
sizeof(std::decay_t<decltype(x.value)>);
- std::unsigned_integral<std::decay_t<decltype(x.value)>>;
+ requires std::unsigned_integral<std::decay_t<decltype(x.value)>>;
}
struct is_input_field<Field> : std::bool_constant<true> {};
@@ -118,6 +118,10 @@ constexpr CORRADE_ALWAYS_INLINE void read_(Tuple&&, input<T, Left> st, std::inde
namespace floormat {
template<std::unsigned_integral T, typename Tuple> constexpr void pack_read(Tuple&& tuple, T value)
+requires requires (const Tuple& tuple) {
+ std::tuple_size_v<Tuple> > 0uz;
+ Pack_impl::is_input_field<std::decay_t<decltype(std::get<0>(tuple))>>::value;
+}
{
constexpr size_t nbits = sizeof(T)*8,
tuple_size = std::tuple_size_v<std::decay_t<Tuple>>;
diff --git a/serialize/packbits-write.cpp b/serialize/packbits-write.cpp
index f261abe5..7dab800a 100644
--- a/serialize/packbits-write.cpp
+++ b/serialize/packbits-write.cpp
@@ -43,4 +43,11 @@ u32 foo1(u32 a, u32 b, u32 c)
} // namespace
+#if 0
+[[maybe_unused]] uint8_t test1(uint8_t a, uint8_t b, uint8_t c)
+{
+ return pack_write(std::tuple{f8<2>{a}, f8<3>{b}, f8<3>{c}});
+}
+#endif
+
} // namespace floormat
diff --git a/serialize/packbits-write.hpp b/serialize/packbits-write.hpp
index 7df095c1..6d98181b 100644
--- a/serialize/packbits-write.hpp
+++ b/serialize/packbits-write.hpp
@@ -71,7 +71,7 @@ namespace floormat {
template<typename Tuple>
requires requires (const Tuple& tuple) {
- std::tuple_size_v<Tuple> > size_t{0};
+ std::tuple_size_v<Tuple> > 0uz;
Pack_impl::is_output_field<std::decay_t<decltype(std::get<0>(tuple))>>::value;
}
[[nodiscard]] constexpr auto pack_write(const Tuple& tuple)