1 #ifndef IOBUFFER_DOT_HPP
2 #define IOBUFFER_DOT_HPP
4 #include "default_init_allocator.hpp"
9 template <typename ByteT
= std::byte
>
12 using buffer_t
= std::vector
<ByteT
, default_init_allocator
<ByteT
>>;
13 using size_type
= typename
buffer_t::size_type
;
16 explicit iobuffer(size_type sz
)
21 auto data() { return buf_
.data(); }
22 auto data() const { return buf_
.data(); }
23 auto size() const { return buf_
.size(); }
25 auto resize(size_type sz
) { return buf_
.resize(sz
); }
26 void shrink_to_fit() { buf_
.shrink_to_fit(); }
28 bool operator==(iobuffer
const& rhs
) const
30 if (this->size() == rhs
.size())
31 return memcmp(this->data(), rhs
.data(), this->size()) == 0;
35 bool operator<(iobuffer
const& rhs
) const
37 if (this->size() == rhs
.size())
38 return memcmp(this->data(), rhs
.data(), this->size()) < 0;
39 return this->size() < rhs
.size();
46 #endif // IOBUFFER_DOT_HPP