From 994916b7eb951725d2a8a21cb08af5198b7821ac Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 13 Sep 2018 03:22:21 -0700 Subject: [PATCH] ircd::buffer: Deconflict buffers templates in separate namespace. --- include/ircd/buffer/buffer.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/include/ircd/buffer/buffer.h b/include/ircd/buffer/buffer.h index f16c12e79..57d877e5e 100644 --- a/include/ircd/buffer/buffer.h +++ b/include/ircd/buffer/buffer.h @@ -77,13 +77,16 @@ namespace ircd::buffer void reverse(const mutable_buffer &buf); void zero(const mutable_buffer &buf); + // Convenience copy to std stream + template std::ostream &operator<<(std::ostream &s, const buffer &buffer); +} + +namespace ircd::buffer::buffers +{ // Iterable of buffers tools template class I, class T> size_t size(const I &buffers); template class I, class T> size_t copy(const mutable_buffer &, const I &buffer); template class I, class T> size_t consume(I &buffers, const size_t &bytes); - - // Convenience copy to std stream - template std::ostream &operator<<(std::ostream &s, const buffer &buffer); template class I, class T> std::ostream &operator<<(std::ostream &s, const I &buffers); } @@ -123,7 +126,7 @@ template class buffers, class T> std::ostream & -ircd::buffer::operator<<(std::ostream &s, const buffers &b) +ircd::buffer::buffers::operator<<(std::ostream &s, const buffers &b) { using it = typename T::iterator; @@ -140,14 +143,16 @@ template class buffers, class T> size_t -ircd::buffer::consume(buffers &b, - const size_t &bytes) +ircd::buffer::buffers::consume(buffers &b, + const size_t &bytes) { ssize_t remain(bytes); for(auto it(std::begin(b)); it != std::end(b) && remain > 0; ++it) { using buffer = typename buffers::value_type; using iterator = typename buffer::iterator; + using ircd::buffer::size; + using ircd::buffer::consume; buffer &b(const_cast(*it)); const ssize_t bsz(size(b)); @@ -164,10 +169,12 @@ template class buffers, class T> size_t -ircd::buffer::copy(const mutable_buffer &dest, - const buffers &b) +ircd::buffer::buffers::copy(const mutable_buffer &dest, + const buffers &b) { using it = typename T::iterator; + using ircd::buffer::copy; + using ircd::buffer::size; size_t ret(0); for(const buffer &b : b) @@ -180,9 +187,10 @@ template class buffers, class T> size_t -ircd::buffer::size(const buffers &b) +ircd::buffer::buffers::size(const buffers &b) { using it = typename T::iterator; + using ircd::buffer::size; return std::accumulate(std::begin(b), std::end(b), size_t(0), [] (auto ret, const buffer &b)