46 :
buffer_(static_cast<unsigned char*>(
50 throw std::bad_alloc();
70 :
buffer_(std::exchange(other.buffer_,
nullptr)),
size_(other.size_) {}
114 auto* new_buffer =
static_cast<unsigned char*
>(
116 if (new_buffer ==
nullptr) {
117 throw std::bad_alloc();
145 [[nodiscard]]
const unsigned char*
data() const noexcept {
return buffer_; }
152 [[nodiscard]] std::size_t
size() const noexcept {
return size_; }
195 instance1.swap(instance2);
Class of basic buffers for binary data.
~basic_binary_buffer()
Destructor.
void swap(basic_binary_buffer &other) noexcept
Swap with another instance.
std::size_t size() const noexcept
Get the size of the buffer.
void resize(std::size_t new_size)
Change the size of the buffer.
basic_binary_buffer(const basic_binary_buffer &other)
Copy constructor.
const unsigned char * data() const noexcept
Get the pointer to the buffer.
basic_binary_buffer(basic_binary_buffer &&other) noexcept
Move constructor.
std::size_t size_
Size of the buffer.
unsigned char * buffer_
Buffer.
basic_binary_buffer & operator=(basic_binary_buffer &&other) noexcept
Move assignment operator.
basic_binary_buffer(std::size_t size)
Constructor.
unsigned char * data() noexcept
Get the pointer to the buffer.
static std::size_t prevent_unsafe_size(std::size_t size)
Change the input to a size which won't cause implementation-defined behaviors of std::malloc and std:...
basic_binary_buffer & operator=(const basic_binary_buffer &other)
Copy assignment operator.
Namespace of internal implementations.
void swap(msgpack_light::details::basic_binary_buffer &instance1, msgpack_light::details::basic_binary_buffer &instance2) noexcept
Implementation of std::swap for msgpack_light::details::basic_binary_buffer.