From f74d52b9be6346ec76c7aede20ec8dea16a70588 Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Mon, 1 Jul 2019 14:37:23 +0200 Subject: [PATCH] buffer.h: fix BufferBuilder const for_each GitOrigin-RevId: a264a7d12975e57c517303e4699e2e73eb1d2211 --- tdutils/td/utils/buffer.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tdutils/td/utils/buffer.h b/tdutils/td/utils/buffer.h index 27add921..2c53a9ca 100644 --- a/tdutils/td/utils/buffer.h +++ b/tdutils/td/utils/buffer.h @@ -288,6 +288,10 @@ class BufferWriter { auto end = buffer_->end_.load(std::memory_order_relaxed); return MutableSlice(buffer_->data_ + buffer_->begin_, buffer_->data_ + end); } + Slice as_slice() const { + auto end = buffer_->end_.load(std::memory_order_relaxed); + return Slice(buffer_->data_ + buffer_->begin_, buffer_->data_ + end); + } MutableSlice prepare_prepend() { if (is_null()) { @@ -743,13 +747,13 @@ class BufferBuilder { template void for_each(F &&f) const & { for (auto &slice : reversed(to_prepend_)) { - f(slice); + f(slice.as_slice()); } if (!buffer_writer_.empty()) { - f(buffer_writer_.as_buffer_slice()); + f(buffer_writer_.as_slice()); } for (auto &slice : to_append_) { - f(slice); + f(slice.as_slice()); } } template