[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/nlitsme/cpputils/master/include/cpputils/datapacking.h [Back]  [Original]

#pragma once #include #include #include #include #include #include #include // todo: add 'P copybytes([int n, ]range-object)' which copies (n or range.size()) bytes // to range, and returns the ptr to the next item to be written. template constexpr bool has_op_difference_v{}; template constexpr bool has_op_difference_v< T, std::void_t< decltype(std::declval()-std::declval()) > > = true; template struct packer_base { P p; P last; packer_base(P first, P last) : p(first), last(last) { } bool eof() const { return p == last; } void require(int n) { if (!have(n)) throw std::runtime_error("not enough data"); } bool have(int n) { // I used to check for difference_type here, unfortunately since c++20 // backinserter now has a difference_type, but no operate-, so checking for that now. if constexpr (has_op_difference_v

) return n


Web Proxy Viewer  |  New URL  |  Original Page