From 97fc4fcd50272dab1d2c6e94019502d42deb4a2c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 Jan 2024 19:49:15 +0100 Subject: a --- serialize/packbits.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'serialize/packbits.cpp') diff --git a/serialize/packbits.cpp b/serialize/packbits.cpp index 86c6f605..634191fc 100644 --- a/serialize/packbits.cpp +++ b/serialize/packbits.cpp @@ -7,6 +7,25 @@ using namespace floormat::detail_Pack; namespace { +template struct check_size_overflow; + +template +struct check_size_overflow, Xs...> +{ + static_assert(std::is_same_v); + static constexpr auto acc = Sum + size_t{N}; + using next_check = check_size_overflow; + static constexpr auto size = next_check::size; + static constexpr bool result = next_check::result; +}; + +template +struct check_size_overflow +{ + static constexpr size_t size = Sum; + static constexpr bool result = Sum <= sizeof(T)*8; +}; + template constexpr inline T lowbits = (T{1} << N)-T{1}; template using us_bits = Bits_; -- cgit v1.2.3