0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-29 00:44:17 +01:00

ircd::buffer: Reverse convenience utils.

This commit is contained in:
Jason Volk 2017-12-18 15:05:01 -07:00
parent acff6139e9
commit 82aa59c5ec

View file

@ -91,6 +91,8 @@ namespace ircd::buffer
template<class it> it copy(it &dest, const it &stop, const const_raw_buffer &);
template<class it> size_t copy(const it &dest, const size_t &max, const const_raw_buffer &buffer);
size_t copy(const mutable_raw_buffer &dst, const const_raw_buffer &src);
size_t reverse(const mutable_raw_buffer &dst, const const_raw_buffer &src);
void reverse(const mutable_raw_buffer &buf);
void zero(const mutable_raw_buffer &buf);
// Iterable of buffers tools
@ -545,6 +547,21 @@ ircd::buffer::operator<<(std::ostream &s, const buffer<it> &buffer)
return s;
}
inline void
ircd::buffer::reverse(const mutable_raw_buffer &buf)
{
std::reverse(data(buf), data(buf) + size(buf));
}
inline size_t
ircd::buffer::reverse(const mutable_raw_buffer &dst,
const const_raw_buffer &src)
{
const size_t ret{std::min(size(dst), size(src))};
std::reverse_copy(data(src), data(src) + ret, data(dst));
return ret;
}
inline size_t
ircd::buffer::copy(const mutable_raw_buffer &dst,
const const_raw_buffer &src)