| 468 | static constexpr uint64_t MAX = 0xffffffffffffffff >> (8 * (8 - Bytes)); |
| 469 | |
| 470 | template <typename Stream, typename I> void Ser(Stream& s, I v) |
| 471 | { |
| 472 | if (v < 0 || v > MAX) throw std::ios_base::failure("CustomUintFormatter value out of range"); |
| 473 | if (BigEndian) { |
| 474 | uint64_t raw = htobe64(v); |
| 475 | s.write({BytePtr(&raw) + 8 - Bytes, Bytes}); |
| 476 | } else { |
| 477 | uint64_t raw = htole64(v); |
| 478 | s.write({BytePtr(&raw), Bytes}); |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | template <typename Stream, typename I> void Unser(Stream& s, I& v) |
| 483 | { |