mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd::buffer: Add convenience closure overload to window_buffer.
This commit is contained in:
parent
1d3f92069f
commit
213826d06c
1 changed files with 13 additions and 1 deletions
|
@ -25,6 +25,7 @@ struct ircd::buffer::window_buffer
|
|||
:mutable_buffer
|
||||
{
|
||||
using closure = std::function<size_t (const mutable_buffer &)>;
|
||||
using closure_cbuf = std::function<const_buffer (const mutable_buffer &)>;
|
||||
|
||||
mutable_buffer base;
|
||||
|
||||
|
@ -35,7 +36,8 @@ struct ircd::buffer::window_buffer
|
|||
explicit operator const_buffer() const;
|
||||
mutable_buffer completed();
|
||||
|
||||
const_buffer operator()(const closure &closure);
|
||||
const_buffer operator()(const closure &);
|
||||
const_buffer operator()(const closure_cbuf &);
|
||||
const_buffer rewind(const size_t &n = 1);
|
||||
const_buffer shift(const size_t &n);
|
||||
|
||||
|
@ -84,6 +86,16 @@ ircd::buffer::window_buffer::rewind(const size_t &n)
|
|||
return completed();
|
||||
}
|
||||
|
||||
inline ircd::buffer::const_buffer
|
||||
ircd::buffer::window_buffer::operator()(const closure_cbuf &closure)
|
||||
{
|
||||
return operator()([&closure]
|
||||
(const mutable_buffer &buf)
|
||||
{
|
||||
return size(closure(buf));
|
||||
});
|
||||
}
|
||||
|
||||
inline ircd::buffer::const_buffer
|
||||
ircd::buffer::window_buffer::operator()(const closure &closure)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue