Support reading an array pointer in util::binary_stream

This commit is contained in:
Nikita Lisitsa 2021-07-13 11:42:46 +03:00
parent fc2b3bd7fd
commit d9c454bc3b

View file

@ -77,6 +77,18 @@ namespace psemek::util
return detail::read_helper<T>::read(data);
}
template <typename T>
T const * read_ptr(std::size_t count)
{
std::size_t size = sizeof(T) * count;
if (data.size() < size)
detail::unexpected_end();
auto p = data.data();
data.remove_prefix(size);
return reinterpret_cast<T const *>(p);
}
char const * read_raw(std::size_t count)
{
if (data.size() < count)