mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd::buffer: Add operator+ to compute a new buffer at offset.
This commit is contained in:
parent
e9a84ff4d7
commit
622e0a56a6
1 changed files with 17 additions and 0 deletions
|
@ -61,6 +61,7 @@ namespace ircd::buffer
|
|||
template<class it> size_t size(const buffer<it> &buffer);
|
||||
template<class it> const it &data(const buffer<it> &buffer);
|
||||
template<class it> size_t consume(buffer<it> &buffer, const size_t &bytes);
|
||||
template<class it> buffer<it> operator+(const buffer<it> &buffer, const size_t &bytes);
|
||||
template<class it> it copy(it &dest, const it &stop, const const_buffer &);
|
||||
size_t copy(const mutable_buffer &dst, const const_buffer &src);
|
||||
size_t reverse(const mutable_buffer &dst, const const_buffer &src);
|
||||
|
@ -564,6 +565,22 @@ ircd::buffer::copy(it &dest,
|
|||
return ret;
|
||||
}
|
||||
|
||||
template<class it>
|
||||
ircd::buffer::buffer<it>
|
||||
ircd::buffer::operator+(const buffer<it> &buffer,
|
||||
const size_t &bytes)
|
||||
{
|
||||
const size_t advance
|
||||
{
|
||||
std::min(bytes, size(buffer))
|
||||
};
|
||||
|
||||
return
|
||||
{
|
||||
begin(buffer) + advance, size(buffer) - advance
|
||||
};
|
||||
}
|
||||
|
||||
template<class it>
|
||||
size_t
|
||||
ircd::buffer::consume(buffer<it> &buffer,
|
||||
|
|
Loading…
Reference in a new issue