From 81d309c3e353ba3209c49c5e5d542a83128b789e Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sun, 12 Jan 2020 22:37:31 +1100 Subject: [PATCH 1/4] Update DynamicBuffer requirements. --- src/buffers.tex | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/buffers.tex b/src/buffers.tex index 837920f..4c5e922 100644 --- a/src/buffers.tex +++ b/src/buffers.tex @@ -455,15 +455,16 @@ \rSec2[buffer.reqmts.dynamicbuffer]{Dynamic buffer requirements} \pnum -A \defn{dynamic buffer} encapsulates memory storage that may be automatically resized as required, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but direct access to the elements is provided to permit them to be efficiently used with I/O operations. \begin{note} Such as the \tcode{send} or \tcode{receive} operations of a socket. The readable bytes would be used as the constant buffer sequence for \tcode{send}, and the writable bytes used as the mutable buffer sequence for \tcode{receive}. \end{note} Data written to the writable bytes of a dynamic buffer object is appended to the readable bytes of the same object. +A \defn{dynamic buffer} encapsulates memory storage that may be automatically resized as required\added{.}\removed{, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but d}\added{D}irect access to the elements is provided to permit them to be efficiently used with I/O operations. \begin{note} Such as the \tcode{send} or \tcode{receive} operations of a socket.\removed{ The readable bytes would be used as the constant buffer sequence for \tcode{send}, and the writable bytes used as the mutable buffer sequence for \tcode{receive}.} \end{note}\removed{ Data written to the writable bytes of a dynamic buffer object is appended to the readable bytes of the same object.} \pnum -A type \tcode{X} meets the \defnnewoldconcept{DynamicBuffer} requirements if it meets the requirements of \oldconcept{Destructible}~(\CppXref{destructible}) and \oldconcept{MoveConstructible}~(\CppXref{moveconstructible}), as well as the additional requirements listed in Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}. +A type \tcode{X} meets the \defnnewoldconcept{DynamicBuffer} requirements if it meets the requirements of \oldconcept{Destructible} (\CppXref{destructible}) and \removed{\oldconcept{MoveConstructible} (\CppXref{moveconstructible})}\added{\oldconcept{CopyConstructible} (\CppXref{copyconstructible})}, as well as the additional requirements listed in Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}. \pnum In Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}, \tcode{x} denotes a value of type \tcode{X}, \tcode{x1} denotes a (possibly const) value of type \tcode{X}, +\added{\tcode{pos} denotes a (possibly const) value of type \tcode{size_t},} and \tcode{n} denotes a (possibly const) value of type \tcode{size_t}. \indextext{requirements!\idxnewoldconcept{DynamicBuffer}}% @@ -484,39 +485,55 @@ \tcode{X::const_buffers_type} & type meeting \newoldconcept{ConstBufferSequence}~(\ref{buffer.reqmts.constbuffersequence}) requirements. & - This type represents the memory associated with the readable bytes. \\ \rowsep + This type represents the \added{underlying} memory \removed{associated with the readable bytes}\added{as non-modifiable bytes}. \\ \rowsep \tcode{X::mutable_buffers_type} & type meeting \newoldconcept{MutableBufferSequence}~(\ref{buffer.reqmts.constbuffersequence}) requirements. & - This type represents the memory associated with the writable bytes. \\ \rowsep + This type represents the \added{underlying} memory \removed{associated with the writable bytes}\added{as modifiable bytes}. \\ \rowsep \tcode{x1.size()} & \tcode{size_t} & - Returns the number of readable bytes. \\ \rowsep + Returns the number of \removed{readable} bytes. \\ \rowsep \tcode{x1.max_size()} & \tcode{size_t} & -Returns the maximum number of bytes, both readable and writable, that can be held by \tcode{x1}. \\ \rowsep +Returns the maximum number of bytes\removed{, both readable and writable,} that can be held by \tcode{x1}. \\ \rowsep \tcode{x1.capacity()} & \tcode{size_t} & -Returns the maximum number of bytes, both readable and writable, that can be held by \tcode{x1} without requiring reallocation. \\ \rowsep +Returns the maximum number of bytes\removed{, both readable and writable,} that can be held by \tcode{x1} without requiring reallocation. \\ \rowsep -\tcode{x1.data()} & -\tcode{X::const_buffers_type} & -Returns a constant buffer sequence \tcode{u} that represents the readable bytes, and where \tcode{buffer_size(u) == size()}. \\ \rowsep +\removed{\tcode{x1.data()}} & +\removed{\tcode{X::const_buffers_type}} & +\removed{Returns a constant buffer sequence \tcode{u} that represents the readable bytes, and where \tcode{buffer_size(u) == size()}.} \\ \rowsep -\tcode{x.prepare(n)} & -\tcode{X::mutable_buffers_type} & -Returns a mutable buffer sequence \tcode{u} representing the writable bytes, and where \tcode{buffer_size(u) == n}. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated.\br \throws\ \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}. \\ \rowsep +\removed{\tcode{x.prepare(n)}} & +\removed{\tcode{X::mutable_buffers_type}} & +\removed{Returns a mutable buffer sequence \tcode{u} representing the writable bytes, and where \tcode{buffer_size(u) == n}. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated.\br \throws\ \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} \\ \rowsep + +\removed{\tcode{x.commit(n)}} & + & +\removed{Appends \tcode{n} bytes from the start of the writable bytes to the end of the readable bytes. The remainder of the writable bytes are discarded. If \tcode{n} is greater than the number of writable bytes, all writable bytes are appended to the readable bytes. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated.} \\ \rowsep + +\added{\tcode{x1.data(pos, n)}} & +\added{\tcode{X::const_buffers_type}} & +\added{Returns a constant buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}.} \\ \rowsep + +\added{\tcode{x.data(pos, n)}} & +\added{\tcode{X::mutable_buffers_type}} & +\added{Returns a mutable buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}.} \\ \rowsep + +\added{\tcode{x.grow(n)}} & + & +\added{Adds \tcode{n} bytes of space at the end of the underlying memory. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated.} \\ \rowsep -\tcode{x.commit(n)} & +\added{\tcode{x.shrink(n)}} & & -Appends \tcode{n} bytes from the start of the writable bytes to the end of the readable bytes. The remainder of the writable bytes are discarded. If \tcode{n} is greater than the number of writable bytes, all writable bytes are appended to the readable bytes. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated. \\ \rowsep +\added{Removes \tcode{n} bytes of space from the end of the underlying memory. If \tcode{n} is greater than the number of bytes, all bytes are discarded. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated.} \\ \rowsep \tcode{x.consume(n)} & & -Removes \tcode{n} bytes from beginning of the readable bytes. If \tcode{n} is greater than the number of readable bytes, all readable bytes are removed. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated. \\ +Removes \tcode{n} bytes from beginning of the \removed{readable} bytes. If \tcode{n} is greater than the number of \removed{readable} bytes, all \removed{readable} bytes are removed. All constant or mutable buffer sequences previously obtained using \tcode{data()} \removed{or \tcode{prepare()} }are invalidated. \\ \end{libreqtab3} From 6185e531b0b8aab04a0666808bd80a30bc4b9372 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Mon, 13 Jan 2020 00:01:01 +1100 Subject: [PATCH 2/4] Update dynamic_vector_buffer and dynamic_string_buffer. --- src/buffers.tex | 164 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 120 insertions(+), 44 deletions(-) diff --git a/src/buffers.tex b/src/buffers.tex index 4c5e922..0d8619b 100644 --- a/src/buffers.tex +++ b/src/buffers.tex @@ -1137,20 +1137,24 @@ explicit dynamic_vector_buffer(vector& vec) noexcept; dynamic_vector_buffer(vector& vec, size_t maximum_size) noexcept; - dynamic_vector_buffer(dynamic_vector_buffer&&) = default; + @\removedcode{dynamic_vector_buffer(dynamic_vector_buffer\&\&) = default;}@ // members: size_t size() const noexcept; size_t max_size() const noexcept; size_t capacity() const noexcept; - const_buffers_type data() const noexcept; - mutable_buffers_type prepare(size_t n); - void commit(size_t n); + @\removedcode{const_buffers_type data() const noexcept;}@ + @\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ + @\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ + @\removedcode{mutable_buffers_type prepare(size_t n);}@ + @\removedcode{void commit(size_t n) noexcept;}@ + @\addedcode{void grow(size_t n);}@ + @\addedcode{void shrink(size_t n);}@ void consume(size_t n); private: vector& vec_; // \expos - size_t size_; // \expos + @\removedcode{size_t size_; // \expos}@ const size_t max_size_; // \expos }; @@ -1170,7 +1174,7 @@ \begin{itemdescr} \pnum -\effects Initializes \tcode{vec_} with \tcode{vec}, \tcode{size_} with \tcode{vec.size()}, and \tcode{max_size_} with \tcode{vec.max_size()}. +\effects Initializes \tcode{vec_} with \tcode{vec}\removed{, \tcode{size_} with \tcode{vec.size()},} and \tcode{max_size_} with \tcode{vec.max_size()}. \end{itemdescr} \indexlibrary{\idxcode{dynamic_vector_buffer}!constructor}% @@ -1184,7 +1188,7 @@ \expects \tcode{vec.size() <= maximum_size}. \pnum -\effects Initializes \tcode{vec_} with \tcode{vec}, \tcode{size_} with \tcode{vec.size()}, and \tcode{max_size_} with \tcode{maximum_size}. +\effects Initializes \tcode{vec_} with \tcode{vec}\removed{, \tcode{size_} with \tcode{vec.size()},} and \tcode{max_size_} with \tcode{maximum_size}. \end{itemdescr} \indexlibrarymember{size}{dynamic_vector_buffer}% @@ -1194,7 +1198,7 @@ \begin{itemdescr} \pnum -\returns \tcode{size_}. +\returns \removed{\tcode{size_}}\added{\tcode{min(vec_.size(), max_size_)}}. \end{itemdescr} \indexlibrarymember{max_size}{dynamic_vector_buffer}% @@ -1214,50 +1218,83 @@ \begin{itemdescr} \pnum -\returns \tcode{vec_.capacity()}. +\returns \removed{\tcode{vec_.capacity()}}\added{\tcode{min(vec_.capacity(), max_size_)}}. \end{itemdescr} \indexlibrarymember{data}{dynamic_vector_buffer}% \begin{itemdecl} -const_buffers_type data() const noexcept; +@\removedcode{const_buffers_type data() const noexcept;}@ \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{buffer(vec_, size_)}. +\removed{\returns \tcode{buffer(vec_, size_)}.} +\end{itemdescr} + +\begin{itemdecl} +@\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ +@\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\returns \tcode{buffer(buffer(vec_, max_size_) + pos, n)}.} \end{itemdescr} \indexlibrarymember{prepare}{dynamic_vector_buffer}% \begin{itemdecl} -mutable_buffers_type prepare(size_t n); +@\removedcode{mutable_buffers_type prepare(size_t n);}@ \end{itemdecl} \begin{itemdescr} \pnum -\effects Performs \tcode{vec_.resize(size_ + n)}. +\removed{\effects Performs \tcode{vec_.resize(size_ + n)}.} \pnum -\returns \tcode{buffer(buffer(vec_) + size_, n)}. +\removed{\returns \tcode{buffer(buffer(vec_) + size_, n)}.} \pnum -\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}. +\removed{\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} \end{itemdescr} \indexlibrarymember{commit}{dynamic_vector_buffer}% \begin{itemdecl} -void commit(size_t n); +@\removedcode{void commit(size_t n);}@ \end{itemdecl} \begin{itemdescr} \pnum -\effects Performs: +\removed{\effects Performs:} \begin{codeblock} -size_ += min(n, vec_.size() - size_); -vec_.resize(size_); +@\removedcode{size_ += min(n, vec_.size() - size_);}@ +@\removedcode{vec_.resize(size_);}@ \end{codeblock} \end{itemdescr} +\indexlibrarymember{grow}{dynamic_vector_buffer}% +\begin{itemdecl} +@\addedcode{void grow(size_t n);}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\effects Performs \addedcode{vec_.resize(size() + n);}.} + +\pnum +\added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} +\end{itemdescr} + +\indexlibrarymember{shrink}{dynamic_vector_buffer}% +\begin{itemdecl} +@\addedcode{void shrink(size_t n);}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\effects Performs \addedcode{vec_.resize(n > size() ? 0 : size() - n);}.} +\end{itemdescr} + \indexlibrarymember{consume}{dynamic_vector_buffer}% \begin{itemdecl} void consume(size_t n); @@ -1267,9 +1304,10 @@ \pnum \effects Performs: \begin{codeblock} -size_t m = min(n, size_); -vec_.erase(vec_.begin(), vec_.begin() + m); -size_ -= m; +@\removedcode{size_t m = min(n, size_);}@ +@\removedcode{vec_.erase(vec_.begin(), vec_.begin() + m);}@ +@\removedcode{size_ -= m;}@ +@\addedcode{vec_.erase(vec_.begin(), vec_.begin() + min(n, size()));}@ \end{codeblock} \end{itemdescr} @@ -1297,20 +1335,24 @@ explicit dynamic_string_buffer(basic_string& str) noexcept; dynamic_string_buffer(basic_string& str, size_t maximum_size) noexcept; - dynamic_string_buffer(dynamic_string_buffer&&) = default; + @\removedcode{dynamic_string_buffer(dynamic_string_buffer\&\&) = default;}@ // members: size_t size() const noexcept; size_t max_size() const noexcept; size_t capacity() const noexcept; - const_buffers_type data() const noexcept; - mutable_buffers_type prepare(size_t n); - void commit(size_t n) noexcept; + @\removedcode{const_buffers_type data() const noexcept;}@ + @\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ + @\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ + @\removedcode{mutable_buffers_type prepare(size_t n);}@ + @\removedcode{void commit(size_t n) noexcept;}@ + @\addedcode{void grow(size_t n);}@ + @\addedcode{void shrink(size_t n);}@ void consume(size_t n); private: basic_string& str_; // \expos - size_t size_; // \expos + @\removedcode{size_t size_; // \expos}@ const size_t max_size_; // \expos }; @@ -1330,7 +1372,7 @@ \begin{itemdescr} \pnum -\effects Initializes \tcode{str_} with \tcode{str}, \tcode{size_} with \tcode{str.size()}, and \tcode{max_size_} with \tcode{str.max_size()}. +\effects Initializes \tcode{str_} with \tcode{str}\removed{, \tcode{size_} with \tcode{str.size()},} and \tcode{max_size_} with \tcode{str.max_size()}. \end{itemdescr} \indexlibrary{\idxcode{dynamic_string_buffer}!constructor}% @@ -1344,7 +1386,7 @@ \expects \tcode{str.size() <= maximum_size}. \pnum -\effects Initializes \tcode{str_} with \tcode{str}, \tcode{size_} with \tcode{str.size()}, and \tcode{max_size_} with \tcode{maximum_size}. +\effects Initializes \tcode{str_} with \tcode{str}\removed{, \tcode{size_} with \tcode{str.size()},} and \tcode{max_size_} with \tcode{maximum_size}. \end{itemdescr} \indexlibrarymember{size}{dynamic_string_buffer}% @@ -1354,7 +1396,7 @@ \begin{itemdescr} \pnum -\returns \tcode{size_}. +\returns \removed{\tcode{size_}}\added{\tcode{min(str_.size(), max_size_)}}. \end{itemdescr} \indexlibrarymember{max_size}{dynamic_string_buffer}% @@ -1374,50 +1416,83 @@ \begin{itemdescr} \pnum -\returns \tcode{str_.capacity()}. +\returns \removed{\tcode{vec_.capacity()}}\added{\tcode{min(str_.capacity(), max_size_)}}. \end{itemdescr} \indexlibrarymember{data}{dynamic_string_buffer}% \begin{itemdecl} -const_buffers_type data() const noexcept; +@\removedcode{const_buffers_type data() const noexcept;}@ \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{buffer(str_, size_)}. +\removed{\returns \tcode{buffer(str_, size_)}.} +\end{itemdescr} + +\begin{itemdecl} +@\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ +@\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\returns \tcode{buffer(buffer(str_, max_size_) + pos, n)}.} \end{itemdescr} \indexlibrarymember{prepare}{dynamic_string_buffer}% \begin{itemdecl} -mutable_buffers_type prepare(size_t n); +@\removedcode{mutable_buffers_type prepare(size_t n);}@ \end{itemdecl} \begin{itemdescr} \pnum -\effects Performs \tcode{str_.resize(size_ + n)}. +\removed{\effects Performs \tcode{str_.resize(size_ + n)}.} \pnum -\returns \tcode{buffer(buffer(str_) + size_, n)}. +\removed{\returns \tcode{buffer(buffer(str_) + size_, n)}.} \pnum -\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}. +\removed{\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} \end{itemdescr} \indexlibrarymember{commit}{dynamic_string_buffer}% \begin{itemdecl} -void commit(size_t n) noexcept; +@\removedcode{void commit(size_t n) noexcept;}@ \end{itemdecl} \begin{itemdescr} \pnum -\effects Performs: +\removed{\effects Performs:} \begin{codeblock} -size_ += min(n, str_.size() - size_); -str_.resize(size_); +@\removedcode{size_ += min(n, str_.size() - size_);}@ +@\removedcode{str_.resize(size_);}@ \end{codeblock} \end{itemdescr} +\indexlibrarymember{grow}{dynamic_string_buffer}% +\begin{itemdecl} +@\addedcode{void grow(size_t n);}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\effects Performs \addedcode{str_.resize(size() + n);}.} + +\pnum +\added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} +\end{itemdescr} + +\indexlibrarymember{shrink}{dynamic_string_buffer}% +\begin{itemdecl} +@\addedcode{void shrink(size_t n);}@ +\end{itemdecl} + +\begin{itemdescr} +\pnum +\added{\effects Performs \addedcode{str_.resize(n > size() ? 0 : size() - n);}.} +\end{itemdescr} + \indexlibrarymember{consume}{dynamic_string_buffer}% \begin{itemdecl} void consume(size_t n); @@ -1427,9 +1502,10 @@ \pnum \effects Performs: \begin{codeblock} -size_t m = min(n, size_); -str_.erase(0, m); -size_ -= m; +@\removedcode{size_t m = min(n, size_);}@ +@\removedcode{str_.erase(0, m);}@ +@\removedcode{size_ -= m;}@ +@\addedcode{str_.erase(0, min(n, size()));}@ \end{codeblock} \end{itemdescr} From 69c00d9c7e11dce153ce01fd97f562149d8dfbb1 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Mon, 13 Jan 2020 09:13:41 +1100 Subject: [PATCH 3/4] Update buffer streams algorithms. --- src/buffers.tex | 52 ++++++++++++------------- src/bufferstreams.tex | 90 +++++++++++++++++++++++++++++-------------- 2 files changed, 87 insertions(+), 55 deletions(-) diff --git a/src/buffers.tex b/src/buffers.tex index 0d8619b..b1bde53 100644 --- a/src/buffers.tex +++ b/src/buffers.tex @@ -174,14 +174,14 @@ error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b); + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, error_code& ec); + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, error_code& ec); // \ref{buffer.async.read}, asynchronous read operations @@ -200,11 +200,11 @@ template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer&& b, CompletionToken&& token); + DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer&& b, + DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, CompletionToken&& token); @@ -229,14 +229,14 @@ error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b); + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, error_code& ec); + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, error_code& ec); // \ref{buffer.async.write}, asynchronous write operations @@ -255,36 +255,36 @@ template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer&& b, CompletionToken&& token); + DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer&& b, + DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, CompletionToken&& token); // \ref{buffer.read.until}, synchronous delimited read operations template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, char delim); + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim, error_code& ec); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, string_view delim); + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, error_code& ec); // \ref{buffer.async.read.until}, asynchronous delimited read operations template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer&& b, char delim, + DynamicBuffer@\removedcode{\&\&}@ b, char delim, CompletionToken&& token); template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer&& b, string_view delim, + DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, CompletionToken&& token); } // inline namespace experimental::net::\namespacever @@ -1237,7 +1237,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\returns \tcode{buffer(buffer(vec_, max_size_) + pos, n)}.} \end{itemdescr} @@ -1278,10 +1278,10 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\effects Performs \addedcode{vec_.resize(size() + n);}.} -\pnum +\addedpnum \added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} \end{itemdescr} @@ -1291,7 +1291,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\effects Performs \addedcode{vec_.resize(n > size() ? 0 : size() - n);}.} \end{itemdescr} @@ -1435,7 +1435,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\returns \tcode{buffer(buffer(str_, max_size_) + pos, n)}.} \end{itemdescr} @@ -1476,10 +1476,10 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\effects Performs \addedcode{str_.resize(size() + n);}.} -\pnum +\addedpnum \added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} \end{itemdescr} @@ -1489,7 +1489,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum +\addedpnum \added{\effects Performs \addedcode{str_.resize(n > size() ? 0 : size() - n);}.} \end{itemdescr} diff --git a/src/bufferstreams.tex b/src/bufferstreams.tex index b1df4e1..1bbac6e 100644 --- a/src/bufferstreams.tex +++ b/src/bufferstreams.tex @@ -384,16 +384,16 @@ \indexlibrary{\idxcode{read}}% \begin{itemdecl} template - size_t read(SyncReadStream& stream, DynamicBuffer&& b); + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, error_code& ec); + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition); template - size_t read(SyncReadStream& stream, DynamicBuffer&& b, + size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, error_code& ec); \end{itemdecl} @@ -407,7 +407,15 @@ \effects Clears \tcode{ec}, then reads data from the synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function. \pnum -Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) is obtained prior to each \tcode{read_some} call using \tcode{b.prepare(N)}, where \tcode{N} is an unspecified value less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \tcode{b.commit(n)}, where \tcode{n} is the return value from \tcode{read_some}. +Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} + +\begin{codeblock} +@\addedcode{auto orig_size = b.size();}@ +@\addedcode{b.grow(N);}@ +@\addedcode{auto x = b.data(orig_size, N);}@ +\end{codeblock} + +where \tcode{N} is an unspecified value less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the return value from \tcode{read_some}. \pnum The \tcode{completion_condition} parameter specifies a completion condition to be called prior to each call to the stream's \tcode{read_some} member function. The completion condition is passed the \tcode{error_code} value from the most recent \tcode{read_some} call, and the total number of bytes transferred in the synchronous read operation so far. The completion condition return value specifies the maximum number of bytes to be read on the subsequent \tcode{read_some} call. Overloads where a completion condition is not specified behave as if called with an object of class \tcode{transfer_all}. @@ -483,11 +491,11 @@ \begin{itemdecl} template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer&& b, CompletionToken&& token); + DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer&& b, + DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, CompletionToken&& token); \end{itemdecl} @@ -504,7 +512,15 @@ \effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing one or more asynchronous read_some operations on the stream. \pnum -Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) is obtained prior to each \tcode{async_read_some} call using \tcode{b.prepare(N)}, where \tcode{N} is an unspecified value such that \tcode{N} is less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \tcode{b.commit(n)}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. +Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{async_read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} + +\begin{codeblock} +@\addedcode{auto orig_size = b.size();}@ +@\addedcode{b.grow(N);}@ +@\addedcode{auto x = b.data(orig_size, N);}@ +\end{codeblock} + +where \tcode{N} is an unspecified value such that \tcode{N} is less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. \pnum The \tcode{completion_condition} parameter specifies a completion condition to be called prior to each asynchronous read_some operation. The completion condition is passed the \tcode{error_code} value from the most recent asynchronous read_some operation, and the total number of bytes transferred in the asynchronous read operation so far. The completion condition return value specifies the maximum number of bytes to be read on the subsequent asynchronous read_some operation. Overloads where a completion condition is not specified behave as if called with an object of class \tcode{transfer_all}. @@ -585,14 +601,14 @@ \indexlibrary{\idxcode{write}}% \begin{itemdecl} template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b); + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, error_code& ec); + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition); template - size_t write(SyncWriteStream& stream, DynamicBuffer&& b, + size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, error_code& ec); \end{itemdecl} @@ -683,11 +699,11 @@ \begin{itemdecl} template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer&& b, CompletionToken&& token); + DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer&& b, + DynamicBuffer@\removedcode{\&\&}@ b, CompletionCondition completion_condition, CompletionToken&& token); \end{itemdecl} @@ -731,30 +747,38 @@ \indexlibrary{\idxcode{read_until}}% \begin{itemdecl} template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, char delim); + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim, error_code& ec); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, string_view delim); + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer&& b, + size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, error_code& ec); \end{itemdecl} \begin{itemdescr} \pnum -\effects Reads data from the buffer-oriented synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function, until the readable bytes of the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contains the specified delimiter \tcode{delim}. +\effects Reads data from the buffer-oriented synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function, until \removed{the readable bytes of }the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contains the specified delimiter \tcode{delim}. \pnum -Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) is obtained prior to each \tcode{read_some} call using \tcode{b.prepare(N)}, where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \tcode{b.commit(n)}, where \tcode{n} is the return value from \tcode{read_some}. +Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} + +\begin{codeblock} +@\addedcode{auto orig_size = b.size();}@ +@\addedcode{b.grow(N);}@ +@\addedcode{auto x = b.data(orig_size, N);}@ +\end{codeblock} + +where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the return value from \tcode{read_some}. \pnum The synchronous read_until operation continues until: \begin{itemize} \item -the readable bytes of \tcode{b} contains the delimiter \tcode{delim}; or +\removed{the readable bytes of }\tcode{b} contains the delimiter \tcode{delim}; or \item \tcode{b.size() == b.max_size()}; or \item @@ -762,10 +786,10 @@ \end{itemize} \pnum -On exit, if the readable bytes of \tcode{b} contains the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} contains the \tcode{error_code} from the most recent \tcode{read_some} call. +On exit, if \removed{the readable bytes of }tcode{b} contains the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} contains the \tcode{error_code} from the most recent \tcode{read_some} call. \pnum -\returns The number of bytes in the readable bytes of \tcode{b} up to and including the delimiter, if present. \begin{note} On completion, the buffer can contain additional bytes following the delimiter. \end{note} Otherwise returns \tcode{0}. +\returns The number of bytes in \removed{the readable bytes of }\tcode{b} up to and including the delimiter, if present. \begin{note} On completion, the buffer can contain additional bytes following the delimiter. \end{note} Otherwise returns \tcode{0}. \end{itemdescr} @@ -776,11 +800,11 @@ \begin{itemdecl} template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer&& b, char delim, + DynamicBuffer@\removedcode{\&\&}@ b, char delim, CompletionToken&& token); template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer&& b, string_view delim, + DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, CompletionToken&& token); \end{itemdecl} @@ -792,17 +816,25 @@ \completionsig \tcode{void(error_code ec, size_t n)}. \pnum -\effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing zero or more asynchronous read_some operations on the stream, until the readable bytes of the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contain the specified delimiter \tcode{delim}. +\effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing zero or more asynchronous read_some operations on the stream, until \removed{the readable bytes of }the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contain\added{s} the specified delimiter \tcode{delim}. \pnum -Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) is obtained prior to each \tcode{async_read_some} call using \tcode{b.prepare(N)}, where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \tcode{b.commit(n)}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. +Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{async_read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} + +\begin{codeblock} +@\addedcode{auto orig_size = b.size();}@ +@\addedcode{b.grow(N);}@ +@\addedcode{auto x = b.data(orig_size, N);}@ +\end{codeblock} + +where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. \pnum The asynchronous read_until operation continues until: \begin{itemize} \item -the readable bytes of \tcode{b} contain the delimiter \tcode{delim}; or +\removed{the readable bytes of }\tcode{b} contain\added{s} the delimiter \tcode{delim}; or \item \tcode{b.size() == b.max_size()}; or \item @@ -816,7 +848,7 @@ If \tcode{delim} is of type \tcode{string_view}, the implementation copies the underlying sequence of characters prior to initiating an asynchronous read_some operation on the stream. \begin{note} This means that the caller is not required to guarantee the validity of the delimiter string after the call to \tcode{async_read_until} returns. \end{note} \pnum -On completion of the asynchronous operation, if the readable bytes of \tcode{b} contain the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} is the \tcode{error_code} from the most recent asynchronous read_some operation. \tcode{n} is the number of readable bytes in \tcode{b} up to and including the delimiter, if present, otherwise \tcode{0}. +On completion of the asynchronous operation, if \removed{the readable bytes of }\tcode{b} contain\added{s} the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} is the \tcode{error_code} from the most recent asynchronous read_some operation. \tcode{n} is the number of readable bytes in \tcode{b} up to and including the delimiter, if present, otherwise \tcode{0}. \end{itemdescr} From 569c7af7466b9d7e09afe304610090a99abd8383 Mon Sep 17 00:00:00 2001 From: Christopher Kohlhoff Date: Sat, 18 Sep 2021 18:56:26 +1000 Subject: [PATCH 4/4] Remove diff markup. --- src/buffers.tex | 258 ++++++++++++------------------------------ src/bufferstreams.tex | 90 +++++++-------- 2 files changed, 120 insertions(+), 228 deletions(-) diff --git a/src/buffers.tex b/src/buffers.tex index b1bde53..b8bfaf2 100644 --- a/src/buffers.tex +++ b/src/buffers.tex @@ -174,14 +174,14 @@ error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); + size_t read(SyncReadStream& stream, DynamicBuffer b); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); + size_t read(SyncReadStream& stream, DynamicBuffer b, error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read(SyncReadStream& stream, DynamicBuffer b, CompletionCondition completion_condition); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read(SyncReadStream& stream, DynamicBuffer b, CompletionCondition completion_condition, error_code& ec); // \ref{buffer.async.read}, asynchronous read operations @@ -200,11 +200,11 @@ template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); + DynamicBuffer b, CompletionToken&& token); template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, + DynamicBuffer b, CompletionCondition completion_condition, CompletionToken&& token); @@ -229,14 +229,14 @@ error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); + size_t write(SyncWriteStream& stream, DynamicBuffer b); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); + size_t write(SyncWriteStream& stream, DynamicBuffer b, error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t write(SyncWriteStream& stream, DynamicBuffer b, CompletionCondition completion_condition); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t write(SyncWriteStream& stream, DynamicBuffer b, CompletionCondition completion_condition, error_code& ec); // \ref{buffer.async.write}, asynchronous write operations @@ -255,36 +255,36 @@ template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); + DynamicBuffer b, CompletionToken&& token); template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, + DynamicBuffer b, CompletionCondition completion_condition, CompletionToken&& token); // \ref{buffer.read.until}, synchronous delimited read operations template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim); + size_t read_until(SyncReadStream& s, DynamicBuffer b, char delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read_until(SyncReadStream& s, DynamicBuffer b, char delim, error_code& ec); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim); + size_t read_until(SyncReadStream& s, DynamicBuffer b, string_view delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read_until(SyncReadStream& s, DynamicBuffer b, string_view delim, error_code& ec); // \ref{buffer.async.read.until}, asynchronous delimited read operations template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer@\removedcode{\&\&}@ b, char delim, + DynamicBuffer b, char delim, CompletionToken&& token); template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, + DynamicBuffer b, string_view delim, CompletionToken&& token); } // inline namespace experimental::net::\namespacever @@ -455,16 +455,16 @@ \rSec2[buffer.reqmts.dynamicbuffer]{Dynamic buffer requirements} \pnum -A \defn{dynamic buffer} encapsulates memory storage that may be automatically resized as required\added{.}\removed{, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but d}\added{D}irect access to the elements is provided to permit them to be efficiently used with I/O operations. \begin{note} Such as the \tcode{send} or \tcode{receive} operations of a socket.\removed{ The readable bytes would be used as the constant buffer sequence for \tcode{send}, and the writable bytes used as the mutable buffer sequence for \tcode{receive}.} \end{note}\removed{ Data written to the writable bytes of a dynamic buffer object is appended to the readable bytes of the same object.} +A \defn{dynamic buffer} encapsulates memory storage that may be automatically resized as required. Direct access to the elements is provided to permit them to be efficiently used with I/O operations. \begin{note} Such as the \tcode{send} or \tcode{receive} operations of a socket. \end{note} \pnum -A type \tcode{X} meets the \defnnewoldconcept{DynamicBuffer} requirements if it meets the requirements of \oldconcept{Destructible} (\CppXref{destructible}) and \removed{\oldconcept{MoveConstructible} (\CppXref{moveconstructible})}\added{\oldconcept{CopyConstructible} (\CppXref{copyconstructible})}, as well as the additional requirements listed in Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}. +A type \tcode{X} meets the \defnnewoldconcept{DynamicBuffer} requirements if it meets the requirements of \oldconcept{Destructible} (\CppXref{destructible}) and \oldconcept{CopyConstructible} (\CppXref{copyconstructible}), as well as the additional requirements listed in Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}. \pnum In Table~\ref{tab:buffer.reqmts.dynamicbuffer.requirements}, \tcode{x} denotes a value of type \tcode{X}, \tcode{x1} denotes a (possibly const) value of type \tcode{X}, -\added{\tcode{pos} denotes a (possibly const) value of type \tcode{size_t},} +\tcode{pos} denotes a (possibly const) value of type \tcode{size_t}, and \tcode{n} denotes a (possibly const) value of type \tcode{size_t}. \indextext{requirements!\idxnewoldconcept{DynamicBuffer}}% @@ -485,55 +485,43 @@ \tcode{X::const_buffers_type} & type meeting \newoldconcept{ConstBufferSequence}~(\ref{buffer.reqmts.constbuffersequence}) requirements. & - This type represents the \added{underlying} memory \removed{associated with the readable bytes}\added{as non-modifiable bytes}. \\ \rowsep + This type represents the underlying memory as non-modifiable bytes. \\ \rowsep \tcode{X::mutable_buffers_type} & type meeting \newoldconcept{MutableBufferSequence}~(\ref{buffer.reqmts.constbuffersequence}) requirements. & - This type represents the \added{underlying} memory \removed{associated with the writable bytes}\added{as modifiable bytes}. \\ \rowsep + This type represents the underlying memory as modifiable bytes. \\ \rowsep \tcode{x1.size()} & \tcode{size_t} & - Returns the number of \removed{readable} bytes. \\ \rowsep + Returns the number of bytes. \\ \rowsep \tcode{x1.max_size()} & \tcode{size_t} & -Returns the maximum number of bytes\removed{, both readable and writable,} that can be held by \tcode{x1}. \\ \rowsep +Returns the maximum number of bytes that can be held by \tcode{x1}. \\ \rowsep \tcode{x1.capacity()} & \tcode{size_t} & -Returns the maximum number of bytes\removed{, both readable and writable,} that can be held by \tcode{x1} without requiring reallocation. \\ \rowsep +Returns the maximum number of bytes that can be held by \tcode{x1} without requiring reallocation. \\ \rowsep -\removed{\tcode{x1.data()}} & -\removed{\tcode{X::const_buffers_type}} & -\removed{Returns a constant buffer sequence \tcode{u} that represents the readable bytes, and where \tcode{buffer_size(u) == size()}.} \\ \rowsep - -\removed{\tcode{x.prepare(n)}} & -\removed{\tcode{X::mutable_buffers_type}} & -\removed{Returns a mutable buffer sequence \tcode{u} representing the writable bytes, and where \tcode{buffer_size(u) == n}. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated.\br \throws\ \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} \\ \rowsep - -\removed{\tcode{x.commit(n)}} & - & -\removed{Appends \tcode{n} bytes from the start of the writable bytes to the end of the readable bytes. The remainder of the writable bytes are discarded. If \tcode{n} is greater than the number of writable bytes, all writable bytes are appended to the readable bytes. All constant or mutable buffer sequences previously obtained using \tcode{data()} or \tcode{prepare()} are invalidated.} \\ \rowsep - -\added{\tcode{x1.data(pos, n)}} & -\added{\tcode{X::const_buffers_type}} & -\added{Returns a constant buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}.} \\ \rowsep +\tcode{x1.data(pos, n)} & +\tcode{X::const_buffers_type} & +Returns a constant buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}. \\ \rowsep -\added{\tcode{x.data(pos, n)}} & -\added{\tcode{X::mutable_buffers_type}} & -\added{Returns a mutable buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}.} \\ \rowsep +\tcode{x.data(pos, n)} & +\tcode{X::mutable_buffers_type} & +Returns a mutable buffer sequence \tcode{u} that represents the region of underlying memory at offset \tcode{pos} and length \tcode{n}. \\ \rowsep -\added{\tcode{x.grow(n)}} & +\tcode{x.grow(n)} & & -\added{Adds \tcode{n} bytes of space at the end of the underlying memory. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated.} \\ \rowsep +Adds \tcode{n} bytes of space at the end of the underlying memory. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated. \\ \rowsep -\added{\tcode{x.shrink(n)}} & +\tcode{x.shrink(n)} & & -\added{Removes \tcode{n} bytes of space from the end of the underlying memory. If \tcode{n} is greater than the number of bytes, all bytes are discarded. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated.} \\ \rowsep +Removes \tcode{n} bytes of space from the end of the underlying memory. If \tcode{n} is greater than the number of bytes, all bytes are discarded. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated. \\ \rowsep \tcode{x.consume(n)} & & -Removes \tcode{n} bytes from beginning of the \removed{readable} bytes. If \tcode{n} is greater than the number of \removed{readable} bytes, all \removed{readable} bytes are removed. All constant or mutable buffer sequences previously obtained using \tcode{data()} \removed{or \tcode{prepare()} }are invalidated. \\ +Removes \tcode{n} bytes from beginning of the bytes. If \tcode{n} is greater than the number of bytes, all bytes are removed. All constant or mutable buffer sequences previously obtained using \tcode{data()} are invalidated. \\ \end{libreqtab3} @@ -1137,24 +1125,19 @@ explicit dynamic_vector_buffer(vector& vec) noexcept; dynamic_vector_buffer(vector& vec, size_t maximum_size) noexcept; - @\removedcode{dynamic_vector_buffer(dynamic_vector_buffer\&\&) = default;}@ // members: size_t size() const noexcept; size_t max_size() const noexcept; size_t capacity() const noexcept; - @\removedcode{const_buffers_type data() const noexcept;}@ - @\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ - @\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ - @\removedcode{mutable_buffers_type prepare(size_t n);}@ - @\removedcode{void commit(size_t n) noexcept;}@ - @\addedcode{void grow(size_t n);}@ - @\addedcode{void shrink(size_t n);}@ + mutable_buffers_type data(size_t pos, size_t n) noexcept; + const_buffers_type data(size_t pos, size_t n) const noexcept; + void grow(size_t n); + void shrink(size_t n); void consume(size_t n); private: vector& vec_; // \expos - @\removedcode{size_t size_; // \expos}@ const size_t max_size_; // \expos }; @@ -1174,7 +1157,7 @@ \begin{itemdescr} \pnum -\effects Initializes \tcode{vec_} with \tcode{vec}\removed{, \tcode{size_} with \tcode{vec.size()},} and \tcode{max_size_} with \tcode{vec.max_size()}. +\effects Initializes \tcode{vec_} with \tcode{vec} and \tcode{max_size_} with \tcode{vec.max_size()}. \end{itemdescr} \indexlibrary{\idxcode{dynamic_vector_buffer}!constructor}% @@ -1188,7 +1171,7 @@ \expects \tcode{vec.size() <= maximum_size}. \pnum -\effects Initializes \tcode{vec_} with \tcode{vec}\removed{, \tcode{size_} with \tcode{vec.size()},} and \tcode{max_size_} with \tcode{maximum_size}. +\effects Initializes \tcode{vec_} with \tcode{vec} and \tcode{max_size_} with \tcode{maximum_size}. \end{itemdescr} \indexlibrarymember{size}{dynamic_vector_buffer}% @@ -1198,7 +1181,7 @@ \begin{itemdescr} \pnum -\returns \removed{\tcode{size_}}\added{\tcode{min(vec_.size(), max_size_)}}. +\returns \tcode{min(vec_.size(), max_size_)}. \end{itemdescr} \indexlibrarymember{max_size}{dynamic_vector_buffer}% @@ -1218,81 +1201,41 @@ \begin{itemdescr} \pnum -\returns \removed{\tcode{vec_.capacity()}}\added{\tcode{min(vec_.capacity(), max_size_)}}. +\returns \tcode{min(vec_.capacity(), max_size_)}. \end{itemdescr} \indexlibrarymember{data}{dynamic_vector_buffer}% \begin{itemdecl} -@\removedcode{const_buffers_type data() const noexcept;}@ +mutable_buffers_type data(size_t pos, size_t n) noexcept; +const_buffers_type data(size_t pos, size_t n) const noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\removed{\returns \tcode{buffer(vec_, size_)}.} -\end{itemdescr} - -\begin{itemdecl} -@\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ -@\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ -\end{itemdecl} - -\begin{itemdescr} -\addedpnum -\added{\returns \tcode{buffer(buffer(vec_, max_size_) + pos, n)}.} +\returns \tcode{buffer(buffer(vec_, max_size_) + pos, n)}. \end{itemdescr} -\indexlibrarymember{prepare}{dynamic_vector_buffer}% +\indexlibrarymember{grow}{dynamic_vector_buffer}% \begin{itemdecl} -@\removedcode{mutable_buffers_type prepare(size_t n);}@ +void grow(size_t n); \end{itemdecl} \begin{itemdescr} \pnum -\removed{\effects Performs \tcode{vec_.resize(size_ + n)}.} - -\pnum -\removed{\returns \tcode{buffer(buffer(vec_) + size_, n)}.} +\effects Performs \tcode{vec_.resize(size() + n);}. \pnum -\removed{\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} -\end{itemdescr} - -\indexlibrarymember{commit}{dynamic_vector_buffer}% -\begin{itemdecl} -@\removedcode{void commit(size_t n);}@ -\end{itemdecl} - -\begin{itemdescr} -\pnum -\removed{\effects Performs:} -\begin{codeblock} -@\removedcode{size_ += min(n, vec_.size() - size_);}@ -@\removedcode{vec_.resize(size_);}@ -\end{codeblock} - -\end{itemdescr} - -\indexlibrarymember{grow}{dynamic_vector_buffer}% -\begin{itemdecl} -@\addedcode{void grow(size_t n);}@ -\end{itemdecl} - -\begin{itemdescr} -\addedpnum -\added{\effects Performs \addedcode{vec_.resize(size() + n);}.} - -\addedpnum -\added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} +\throws \tcode{length_error} if \tcode{size() > max_size() || max_size() - size() < n}. \end{itemdescr} \indexlibrarymember{shrink}{dynamic_vector_buffer}% \begin{itemdecl} -@\addedcode{void shrink(size_t n);}@ +void shrink(size_t n); \end{itemdecl} \begin{itemdescr} -\addedpnum -\added{\effects Performs \addedcode{vec_.resize(n > size() ? 0 : size() - n);}.} +\pnum +\effects Performs \tcode{vec_.resize(n > size() ? 0 : size() - n);}. \end{itemdescr} \indexlibrarymember{consume}{dynamic_vector_buffer}% @@ -1304,10 +1247,7 @@ \pnum \effects Performs: \begin{codeblock} -@\removedcode{size_t m = min(n, size_);}@ -@\removedcode{vec_.erase(vec_.begin(), vec_.begin() + m);}@ -@\removedcode{size_ -= m;}@ -@\addedcode{vec_.erase(vec_.begin(), vec_.begin() + min(n, size()));}@ +vec_.erase(vec_.begin(), vec_.begin() + min(n, size())); \end{codeblock} \end{itemdescr} @@ -1335,24 +1275,19 @@ explicit dynamic_string_buffer(basic_string& str) noexcept; dynamic_string_buffer(basic_string& str, size_t maximum_size) noexcept; - @\removedcode{dynamic_string_buffer(dynamic_string_buffer\&\&) = default;}@ // members: size_t size() const noexcept; size_t max_size() const noexcept; size_t capacity() const noexcept; - @\removedcode{const_buffers_type data() const noexcept;}@ - @\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ - @\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ - @\removedcode{mutable_buffers_type prepare(size_t n);}@ - @\removedcode{void commit(size_t n) noexcept;}@ - @\addedcode{void grow(size_t n);}@ - @\addedcode{void shrink(size_t n);}@ + mutable_buffers_type data(size_t pos, size_t n) noexcept; + const_buffers_type data(size_t pos, size_t n) const noexcept; + void grow(size_t n); + void shrink(size_t n); void consume(size_t n); private: basic_string& str_; // \expos - @\removedcode{size_t size_; // \expos}@ const size_t max_size_; // \expos }; @@ -1372,7 +1307,7 @@ \begin{itemdescr} \pnum -\effects Initializes \tcode{str_} with \tcode{str}\removed{, \tcode{size_} with \tcode{str.size()},} and \tcode{max_size_} with \tcode{str.max_size()}. +\effects Initializes \tcode{str_} with \tcode{str} and \tcode{max_size_} with \tcode{str.max_size()}. \end{itemdescr} \indexlibrary{\idxcode{dynamic_string_buffer}!constructor}% @@ -1386,7 +1321,7 @@ \expects \tcode{str.size() <= maximum_size}. \pnum -\effects Initializes \tcode{str_} with \tcode{str}\removed{, \tcode{size_} with \tcode{str.size()},} and \tcode{max_size_} with \tcode{maximum_size}. +\effects Initializes \tcode{str_} with \tcode{str} and \tcode{max_size_} with \tcode{maximum_size}. \end{itemdescr} \indexlibrarymember{size}{dynamic_string_buffer}% @@ -1396,7 +1331,7 @@ \begin{itemdescr} \pnum -\returns \removed{\tcode{size_}}\added{\tcode{min(str_.size(), max_size_)}}. +\returns \tcode{min(str_.size(), max_size_)}. \end{itemdescr} \indexlibrarymember{max_size}{dynamic_string_buffer}% @@ -1416,81 +1351,41 @@ \begin{itemdescr} \pnum -\returns \removed{\tcode{vec_.capacity()}}\added{\tcode{min(str_.capacity(), max_size_)}}. +\returns \tcode{min(str_.capacity(), max_size_)}. \end{itemdescr} \indexlibrarymember{data}{dynamic_string_buffer}% \begin{itemdecl} -@\removedcode{const_buffers_type data() const noexcept;}@ +mutable_buffers_type data(size_t pos, size_t n) noexcept; +const_buffers_type data(size_t pos, size_t n) const noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\removed{\returns \tcode{buffer(str_, size_)}.} -\end{itemdescr} - -\begin{itemdecl} -@\addedcode{mutable_buffers_type data(size_t pos, size_t n) noexcept;}@ -@\addedcode{const_buffers_type data(size_t pos, size_t n) const noexcept;}@ -\end{itemdecl} - -\begin{itemdescr} -\addedpnum -\added{\returns \tcode{buffer(buffer(str_, max_size_) + pos, n)}.} +\returns \tcode{buffer(buffer(str_, max_size_) + pos, n)}. \end{itemdescr} -\indexlibrarymember{prepare}{dynamic_string_buffer}% +\indexlibrarymember{grow}{dynamic_string_buffer}% \begin{itemdecl} -@\removedcode{mutable_buffers_type prepare(size_t n);}@ +void grow(size_t n); \end{itemdecl} \begin{itemdescr} \pnum -\removed{\effects Performs \tcode{str_.resize(size_ + n)}.} - -\pnum -\removed{\returns \tcode{buffer(buffer(str_) + size_, n)}.} +\effects Performs \tcode{str_.resize(size() + n);}. \pnum -\removed{\throws \tcode{length_error} if \tcode{size() + n} exceeds \tcode{max_size()}.} -\end{itemdescr} - -\indexlibrarymember{commit}{dynamic_string_buffer}% -\begin{itemdecl} -@\removedcode{void commit(size_t n) noexcept;}@ -\end{itemdecl} - -\begin{itemdescr} -\pnum -\removed{\effects Performs:} -\begin{codeblock} -@\removedcode{size_ += min(n, str_.size() - size_);}@ -@\removedcode{str_.resize(size_);}@ -\end{codeblock} - -\end{itemdescr} - -\indexlibrarymember{grow}{dynamic_string_buffer}% -\begin{itemdecl} -@\addedcode{void grow(size_t n);}@ -\end{itemdecl} - -\begin{itemdescr} -\addedpnum -\added{\effects Performs \addedcode{str_.resize(size() + n);}.} - -\addedpnum -\added{\throws \tcode{length_error} if \addedcode{size() > max_size() || max_size() - size() < n}.} +\throws \tcode{length_error} if \tcode{size() > max_size() || max_size() - size() < n}. \end{itemdescr} \indexlibrarymember{shrink}{dynamic_string_buffer}% \begin{itemdecl} -@\addedcode{void shrink(size_t n);}@ +void shrink(size_t n); \end{itemdecl} \begin{itemdescr} -\addedpnum -\added{\effects Performs \addedcode{str_.resize(n > size() ? 0 : size() - n);}.} +\pnum +\effects Performs \tcode{str_.resize(n > size() ? 0 : size() - n);}. \end{itemdescr} \indexlibrarymember{consume}{dynamic_string_buffer}% @@ -1502,10 +1397,7 @@ \pnum \effects Performs: \begin{codeblock} -@\removedcode{size_t m = min(n, size_);}@ -@\removedcode{str_.erase(0, m);}@ -@\removedcode{size_ -= m;}@ -@\addedcode{str_.erase(0, min(n, size()));}@ +str_.erase(0, min(n, size())); \end{codeblock} \end{itemdescr} diff --git a/src/bufferstreams.tex b/src/bufferstreams.tex index 1bbac6e..7d171fe 100644 --- a/src/bufferstreams.tex +++ b/src/bufferstreams.tex @@ -384,16 +384,16 @@ \indexlibrary{\idxcode{read}}% \begin{itemdecl} template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); + size_t read(SyncReadStream& stream, DynamicBuffer b); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); + size_t read(SyncReadStream& stream, DynamicBuffer b, error_code& ec); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read(SyncReadStream& stream, DynamicBuffer b, CompletionCondition completion_condition); template - size_t read(SyncReadStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read(SyncReadStream& stream, DynamicBuffer b, CompletionCondition completion_condition, error_code& ec); \end{itemdecl} @@ -407,15 +407,15 @@ \effects Clears \tcode{ec}, then reads data from the synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function. \pnum -Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} +Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \tcode{x} is obtained prior to each \tcode{read_some} call by performing: \begin{codeblock} -@\addedcode{auto orig_size = b.size();}@ -@\addedcode{b.grow(N);}@ -@\addedcode{auto x = b.data(orig_size, N);}@ +auto orig_size = b.size(); +b.grow(N); +auto x = b.data(orig_size, N); \end{codeblock} -where \tcode{N} is an unspecified value less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the return value from \tcode{read_some}. +where \tcode{N} is an unspecified value less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \tcode{b.shrink(N - n)}, where \tcode{n} is the return value from \tcode{read_some}. \pnum The \tcode{completion_condition} parameter specifies a completion condition to be called prior to each call to the stream's \tcode{read_some} member function. The completion condition is passed the \tcode{error_code} value from the most recent \tcode{read_some} call, and the total number of bytes transferred in the synchronous read operation so far. The completion condition return value specifies the maximum number of bytes to be read on the subsequent \tcode{read_some} call. Overloads where a completion condition is not specified behave as if called with an object of class \tcode{transfer_all}. @@ -491,11 +491,11 @@ \begin{itemdecl} template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); + DynamicBuffer b, CompletionToken&& token); template @\DEDUCED@ async_read(AsyncReadStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, + DynamicBuffer b, CompletionCondition completion_condition, CompletionToken&& token); \end{itemdecl} @@ -512,15 +512,15 @@ \effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing one or more asynchronous read_some operations on the stream. \pnum -Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{async_read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} +Data is placed into the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \tcode{x} is obtained prior to each \tcode{async_read_some} call by performing: \begin{codeblock} -@\addedcode{auto orig_size = b.size();}@ -@\addedcode{b.grow(N);}@ -@\addedcode{auto x = b.data(orig_size, N);}@ +auto orig_size = b.size(); +b.grow(N); +auto x = b.data(orig_size, N); \end{codeblock} -where \tcode{N} is an unspecified value such that \tcode{N} is less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. +where \tcode{N} is an unspecified value such that \tcode{N} is less than or equal to \tcode{b.max_size() - b.size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \tcode{b.shrink(N - n)}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. \pnum The \tcode{completion_condition} parameter specifies a completion condition to be called prior to each asynchronous read_some operation. The completion condition is passed the \tcode{error_code} value from the most recent asynchronous read_some operation, and the total number of bytes transferred in the asynchronous read operation so far. The completion condition return value specifies the maximum number of bytes to be read on the subsequent asynchronous read_some operation. Overloads where a completion condition is not specified behave as if called with an object of class \tcode{transfer_all}. @@ -601,14 +601,14 @@ \indexlibrary{\idxcode{write}}% \begin{itemdecl} template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b); + size_t write(SyncWriteStream& stream, DynamicBuffer b); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, error_code& ec); + size_t write(SyncWriteStream& stream, DynamicBuffer b, error_code& ec); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t write(SyncWriteStream& stream, DynamicBuffer b, CompletionCondition completion_condition); template - size_t write(SyncWriteStream& stream, DynamicBuffer@\removedcode{\&\&}@ b, + size_t write(SyncWriteStream& stream, DynamicBuffer b, CompletionCondition completion_condition, error_code& ec); \end{itemdecl} @@ -699,11 +699,11 @@ \begin{itemdecl} template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, CompletionToken&& token); + DynamicBuffer b, CompletionToken&& token); template @\DEDUCED@ async_write(AsyncWriteStream& stream, - DynamicBuffer@\removedcode{\&\&}@ b, + DynamicBuffer b, CompletionCondition completion_condition, CompletionToken&& token); \end{itemdecl} @@ -747,38 +747,38 @@ \indexlibrary{\idxcode{read_until}}% \begin{itemdecl} template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, char delim); + size_t read_until(SyncReadStream& s, DynamicBuffer b, char delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read_until(SyncReadStream& s, DynamicBuffer b, char delim, error_code& ec); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, string_view delim); + size_t read_until(SyncReadStream& s, DynamicBuffer b, string_view delim); template - size_t read_until(SyncReadStream& s, DynamicBuffer@\removedcode{\&\&}@ b, + size_t read_until(SyncReadStream& s, DynamicBuffer b, string_view delim, error_code& ec); \end{itemdecl} \begin{itemdescr} \pnum -\effects Reads data from the buffer-oriented synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function, until \removed{the readable bytes of }the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contains the specified delimiter \tcode{delim}. +\effects Reads data from the buffer-oriented synchronous read stream~(\ref{buffer.stream.reqmts.syncreadstream}) object \tcode{stream} by performing zero or more calls to the stream's \tcode{read_some} member function, until the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contains the specified delimiter \tcode{delim}. \pnum -Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} +Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \tcode{x} is obtained prior to each \tcode{read_some} call by performing: \begin{codeblock} -@\addedcode{auto orig_size = b.size();}@ -@\addedcode{b.grow(N);}@ -@\addedcode{auto x = b.data(orig_size, N);}@ +auto orig_size = b.size(); +b.grow(N); +auto x = b.data(orig_size, N); \end{codeblock} -where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the return value from \tcode{read_some}. +where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of \tcode{read_some} calls performed on the stream. \end{note} After each \tcode{read_some} call, the implementation performs \tcode{b.shrink(N - n)}, where \tcode{n} is the return value from \tcode{read_some}. \pnum The synchronous read_until operation continues until: \begin{itemize} \item -\removed{the readable bytes of }\tcode{b} contains the delimiter \tcode{delim}; or +\tcode{b} contains the delimiter \tcode{delim}; or \item \tcode{b.size() == b.max_size()}; or \item @@ -786,10 +786,10 @@ \end{itemize} \pnum -On exit, if \removed{the readable bytes of }tcode{b} contains the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} contains the \tcode{error_code} from the most recent \tcode{read_some} call. +On exit, if \tcode{b} contains the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} contains the \tcode{error_code} from the most recent \tcode{read_some} call. \pnum -\returns The number of bytes in \removed{the readable bytes of }\tcode{b} up to and including the delimiter, if present. \begin{note} On completion, the buffer can contain additional bytes following the delimiter. \end{note} Otherwise returns \tcode{0}. +\returns The number of bytes in \tcode{b} up to and including the delimiter, if present. \begin{note} On completion, the buffer can contain additional bytes following the delimiter. \end{note} Otherwise returns \tcode{0}. \end{itemdescr} @@ -800,11 +800,11 @@ \begin{itemdecl} template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer@\removedcode{\&\&}@ b, char delim, + DynamicBuffer b, char delim, CompletionToken&& token); template @\DEDUCED@ async_read_until(AsyncReadStream& s, - DynamicBuffer@\removedcode{\&\&}@ b, string_view delim, + DynamicBuffer b, string_view delim, CompletionToken&& token); \end{itemdecl} @@ -816,25 +816,25 @@ \completionsig \tcode{void(error_code ec, size_t n)}. \pnum -\effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing zero or more asynchronous read_some operations on the stream, until \removed{the readable bytes of }the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contain\added{s} the specified delimiter \tcode{delim}. +\effects Initiates an asynchronous operation to read data from the buffer-oriented asynchronous read stream~(\ref{buffer.stream.reqmts.asyncreadstream}) object \tcode{stream} by performing zero or more asynchronous read_some operations on the stream, until the dynamic buffer~(\ref{buffer.reqmts.dynamicbuffer}) object \tcode{b} contains the specified delimiter \tcode{delim}. \pnum -Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \added{\tcode{x} }is obtained prior to each \tcode{async_read_some} call \removed{using \tcode{b.prepare(N)},}\added{by performing:} +Data is placed into the dynamic buffer object \tcode{b}. A mutable buffer sequence~(\ref{buffer.reqmts.mutablebuffersequence}) \tcode{x} is obtained prior to each \tcode{async_read_some} call by performing: \begin{codeblock} -@\addedcode{auto orig_size = b.size();}@ -@\addedcode{b.grow(N);}@ -@\addedcode{auto x = b.data(orig_size, N);}@ +auto orig_size = b.size(); +b.grow(N); +auto x = b.data(orig_size, N); \end{codeblock} -where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \removed{\tcode{b.commit(n)}}\added{\tcode{b.shrink(N - n)}}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. +where \tcode{N} is an unspecified value such that \tcode{N <= max_size() - size()}. \begin{note} Implementations can use \tcode{b.capacity()} when determining \tcode{N}, to minimize the number of asynchronous read_some operations performed on the stream. \end{note} After the completion of each asynchronous read_some operation, the implementation performs \tcode{b.shrink(N - n)}, where \tcode{n} is the value passed to the asynchronous read_some operation's completion handler. \pnum The asynchronous read_until operation continues until: \begin{itemize} \item -\removed{the readable bytes of }\tcode{b} contain\added{s} the delimiter \tcode{delim}; or +\tcode{b} contains the delimiter \tcode{delim}; or \item \tcode{b.size() == b.max_size()}; or \item @@ -848,7 +848,7 @@ If \tcode{delim} is of type \tcode{string_view}, the implementation copies the underlying sequence of characters prior to initiating an asynchronous read_some operation on the stream. \begin{note} This means that the caller is not required to guarantee the validity of the delimiter string after the call to \tcode{async_read_until} returns. \end{note} \pnum -On completion of the asynchronous operation, if \removed{the readable bytes of }\tcode{b} contain\added{s} the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} is the \tcode{error_code} from the most recent asynchronous read_some operation. \tcode{n} is the number of readable bytes in \tcode{b} up to and including the delimiter, if present, otherwise \tcode{0}. +On completion of the asynchronous operation, if \tcode{b} contains the delimiter, \tcode{ec} is set such that \tcode{!ec} is \tcode{true}. Otherwise, if \tcode{b.size() == b.max_size()}, \tcode{ec} is set such that \tcode{ec == stream_errc::not_found}. If \tcode{b.size() < b.max_size()}, \tcode{ec} is the \tcode{error_code} from the most recent asynchronous read_some operation. \tcode{n} is the number of readable bytes in \tcode{b} up to and including the delimiter, if present, otherwise \tcode{0}. \end{itemdescr}