mirror of
https://github.com/matrix-construct/construct
synced 2024-10-04 22:58:52 +02:00
ircd::buffer: Add null()/empty() participation.
This commit is contained in:
parent
e2923336b8
commit
a8b3d08c3a
1 changed files with 24 additions and 0 deletions
|
@ -81,6 +81,9 @@ namespace ircd::buffer
|
|||
template<class it> it rend(const buffer<it> &buffer);
|
||||
|
||||
// Single buffer tools
|
||||
template<class it> bool null(const buffer<it> &buffer);
|
||||
template<class it> bool empty(const buffer<it> &buffer);
|
||||
template<class it> bool operator!(const buffer<it> &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);
|
||||
|
@ -569,6 +572,27 @@ ircd::buffer::size(const buffer<it> &buffer)
|
|||
return std::distance(get<0>(buffer), get<1>(buffer));
|
||||
}
|
||||
|
||||
template<class it>
|
||||
bool
|
||||
ircd::buffer::operator!(const buffer<it> &buffer)
|
||||
{
|
||||
return empty(buffer);
|
||||
}
|
||||
|
||||
template<class it>
|
||||
bool
|
||||
ircd::buffer::empty(const buffer<it> &buffer)
|
||||
{
|
||||
return null(buffer) || !std::distance(get<0>(buffer), get<1>(buffer));
|
||||
}
|
||||
|
||||
template<class it>
|
||||
bool
|
||||
ircd::buffer::null(const buffer<it> &buffer)
|
||||
{
|
||||
return get<0>(buffer) == nullptr;
|
||||
}
|
||||
|
||||
template<class it>
|
||||
it
|
||||
ircd::buffer::rend(const buffer<it> &buffer)
|
||||
|
|
Loading…
Reference in a new issue