mirror of
https://github.com/matrix-construct/construct
synced 2024-07-10 20:48:34 +02:00
ircd::buffer: Add null()/empty() participation.
This commit is contained in:
parent
e2923336b8
commit
a8b3d08c3a
|
@ -81,6 +81,9 @@ namespace ircd::buffer
|
||||||
template<class it> it rend(const buffer<it> &buffer);
|
template<class it> it rend(const buffer<it> &buffer);
|
||||||
|
|
||||||
// Single buffer tools
|
// 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> size_t size(const buffer<it> &buffer);
|
||||||
template<class it> const it &data(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> 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));
|
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>
|
template<class it>
|
||||||
it
|
it
|
||||||
ircd::buffer::rend(const buffer<it> &buffer)
|
ircd::buffer::rend(const buffer<it> &buffer)
|
||||||
|
|
Loading…
Reference in a new issue