Boost logo

Boost :

Subject: Re: [boost] [Beast] Questions Before Review
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-06-25 23:42:57


On 25/06/2017 22:48, Vinnie Falco via Boost wrote:
> On Sun, Jun 25, 2017 at 2:36 PM, Niall Douglas via Boost
> <boost_at_[hidden]> wrote:
>> Where you need to consume or produce arbitrary scatter-gather buffers,
>> use gsl::span<T> or equivalent.
>
> As gsl::span<> is only capable of representing ranges of elements
> contiguous in memory, it is not capable of representing the majority
> of Beast's buffer sequences. Examples:

Think gsl::span<gsl::span<char>>.

Actually AFIO v2 uses gsl::span<std::pair<char *, size_t>>, but that's
to avoid the bounds check per buffer that gsl may do. In your case that
bounds check won't be as important, so gsl::span<gsl::span<char>> makes
lots of sense. Not least for all the extra automated static analysis you
get for free.

>> I certainly can see that char iterators are going to get used a lot
>
> Beast never templates on the character type. All operations on
> structured data (for example HTTP headers) are performed on a single
> contiguous memory buffer of chars. This is done for performance
> reasons.

Hmm. I find that highly surprising. I'd have thought that as the HTTP
data comes in - in chunks - your code would work with discontiguous storage.

Are you memory copying instead?

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk