Add operator+= to const_buffer and mutable_buffer.
diff --git a/asio/include/asio/buffer.hpp b/asio/include/asio/buffer.hpp
index 5d028fb..e238c72 100644
--- a/asio/include/asio/buffer.hpp
+++ b/asio/include/asio/buffer.hpp
@@ -134,6 +134,15 @@
return size_;
}
+ /// Move the start of the buffer by the specified number of bytes.
+ mutable_buffer& operator+=(std::size_t n) ASIO_NOEXCEPT
+ {
+ std::size_t offset = n < size_ ? n : size_;
+ data_ = static_cast<char*>(data_) + offset;
+ size_ -= offset;
+ return *this;
+ }
+
private:
void* data_;
std::size_t size_;
@@ -269,6 +278,15 @@
return size_;
}
+ /// Move the start of the buffer by the specified number of bytes.
+ const_buffer& operator+=(std::size_t n) ASIO_NOEXCEPT
+ {
+ std::size_t offset = n < size_ ? n : size_;
+ data_ = static_cast<const char*>(data_) + offset;
+ size_ -= offset;
+ return *this;
+ }
+
private:
const void* data_;
std::size_t size_;
diff --git a/asio/src/tests/unit/buffer.cpp b/asio/src/tests/unit/buffer.cpp
index fa6ba79..af749de 100644
--- a/asio/src/tests/unit/buffer.cpp
+++ b/asio/src/tests/unit/buffer.cpp
@@ -78,6 +78,7 @@
// mutable_buffer operators.
+ mb1 += 128;
mb1 = mb2 + 128;
mb1 = 128 + mb2;
@@ -114,6 +115,7 @@
// const_buffer operators.
+ cb1 += 128;
cb1 = cb2 + 128;
cb1 = 128 + cb2;