diff --git a/include/ircd/buffer.h b/include/ircd/buffer.h index ea6823911..e352911f8 100644 --- a/include/ircd/buffer.h +++ b/include/ircd/buffer.h @@ -149,16 +149,13 @@ struct ircd::buffer::buffer struct ircd::buffer::mutable_buffer :buffer { - using iterator = typename buffer::iterator; - using value_type = typename buffer::value_type; - // Conversion offered for the analogous asio buffer operator boost::asio::mutable_buffer() const; // Allows boost::spirit to append to the buffer; this means the size() of // this buffer becomes a consumption counter and the real size of the buffer // must be kept separately. This is the lowlevel basis for a stream buffer. - void insert(const iterator &it, const value_type &v) + void insert(char *const &it, const value_type &v) { assert(it >= this->begin() && it <= this->end()); memmove(it + 1, it, std::distance(it, this->end())); @@ -169,23 +166,27 @@ struct ircd::buffer::mutable_buffer using buffer::buffer; mutable_buffer() - :buffer{} + :buffer{} + {} + + mutable_buffer(const buffer &b) + :buffer{b} {} template - mutable_buffer(value_type (&buf)[SIZE]) - :buffer{buf, SIZE} + mutable_buffer(char (&buf)[SIZE]) + :buffer{buf, SIZE} {} template - mutable_buffer(std::array &buf) - :buffer{reinterpret_cast(buf.data()), SIZE} + mutable_buffer(std::array &buf) + :buffer{buf.data(), SIZE} {} // lvalue string reference offered to write through to a std::string as // the buffer. not explicit; should be hard to bind by accident... mutable_buffer(std::string &buf) - :mutable_buffer{const_cast(buf.data()), buf.size()} + :mutable_buffer{const_cast(buf.data()), buf.size()} {} mutable_buffer(const std::function &closure) @@ -197,38 +198,38 @@ struct ircd::buffer::mutable_buffer struct ircd::buffer::const_buffer :buffer { - using iterator = typename buffer::iterator; - using value_type = typename buffer::value_type; - using mutable_value_type = typename std::remove_const::type; - operator boost::asio::const_buffer() const; using buffer::buffer; const_buffer() - :buffer{} + :buffer{} + {} + + const_buffer(const buffer &b) + :buffer{b} + {} + + const_buffer(const buffer &b) + :buffer{data(b), size(b)} {} template - const_buffer(const value_type (&buf)[SIZE]) - :buffer{buf, SIZE} + const_buffer(const char (&buf)[SIZE]) + :buffer{buf, SIZE} {} template - const_buffer(const std::array &buf) - :buffer{reinterpret_cast(buf.data()), SIZE} + const_buffer(const std::array &buf) + :buffer{reinterpret_cast(buf.data()), SIZE} {} const_buffer(const mutable_buffer &b) - :buffer{reinterpret_cast(data(b)), size(b)} + :buffer{data(b), size(b)} {} const_buffer(const string_view &s) - :buffer{reinterpret_cast(s.data()), s.size()} - {} - - explicit const_buffer(const std::string &s) - :buffer{reinterpret_cast(s.data()), s.size()} + :buffer{data(s), size(s)} {} };