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(); }
24 auto resize(size_type sz
) { return buf_
.resize(sz
); }
25 void shrink_to_fit() { buf_
.shrink_to_fit(); }
27 auto begin() const { return buf_
.begin(); }
28 auto end() const { return buf_
.end(); }
30 bool operator==(iobuffer
const& rhs
) const
32 if (this->size() == rhs
.size())
33 return memcmp(this->data(), rhs
.data(), this->size()) == 0;
37 bool operator<(iobuffer
const& rhs
) const
39 if (this->size() == rhs
.size())
40 return memcmp(this->data(), rhs
.data(), this->size()) < 0;
41 return this->size() < rhs
.size();
48 #endif // IOBUFFER_DOT_HPP