Boost Users :
Subject: Re: [Boost-users] [boost] Networking TS + Beast, NEW Tutorials, Read this to learn std::net !!!
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2019-03-15 00:19:36
On Thu, Mar 14, 2019 at 5:09 PM Ivan Matek <libbooze_at_[hidden]> wrote:
> Quite a weird pattern, where buffer does not have member begin, end.
> Maybe a sentence or two describing the rationale and complexity would be nice.
> I know it is O(1), but it is weird that begin/end are called on pointer.
Yeah, well... that's a sore subject. First of all I did not invent
these buffer concepts, they are part of Asio and Networking TS. And
they *used* to have begin() and end(), but then the C++ Standards
Committee decided that they didn't like `const_buffers_1` and
`mutable_buffers_1`, so they got rid of them in the TS draft. Then
they realized that having `const_buffer::begin()` would be confusing.
Does it refer to the beginning of the buffer sequence, or does it
refer to the first byte of that buffer? They decided to get rid of
begin/end entirely for the buffer types and add buffer_sequence_begin
and buffer_sequence_end in its place. And this is why we can't have
> std::size_t read_line
> I am tired, but is this function O(n^2)?
It starts over from the beginning of the range so there can be some
overlap of the searching, yes.
> cb += bytes_transferred; // adjust the pointer and size
> I would maybe switch to write instead of write_some to keep the code shorter, and mention write_some as another option in text.
Well the purpose of this example is to show the looping.
> (error_code ec, std::size_t bytes_transferred)
> For learning purposes I would capture something in lambda by value and note that reference capture would be buggy.
That is something I might consider!! Remember though I"m stuck in
C++11 so no lambda capture assignment expressions.
Appreciate the feedback!
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net