Boost logo

Boost :

From: Roberto Hinz (robhz786_at_[hidden])
Date: 2019-09-01 16:12:16

On Sun, Sep 1, 2019 at 11:59 AM Bjorn Reese via Boost <boost_at_[hidden]>

> On 9/1/19 3:10 PM, Roberto Hinz via Boost wrote:
> > outbuf can be used to binary data, but the basic_cstr_writer class
> > in particular may not be suitable for that, since its finish() function
> > aways writes a terminating zero, requiring an extra space in the
> > destination string. Perhaps we could add another class template,
> > `basic_bin_writer`, that would never write a terminating character.
> I was thinking more broadly than basic_cstr_write which I happened to
> quote. I may want my template classes to operate on the return type
> of any writer in a consistent manner. This is possible if they adhere
> to ContiguousRange and SizedRange as suggested.

It might be quite a challenge to keep such consistency among writers.
Some of them write to file. There is one of them that doesn't actually
write anything, but just ignores all content ( the `discarded_outbuf`
which is documented I but forgot to implement ). What should finish()
return in those cases? And, of course, there are the user-defined
writers. We want the library to work in all sort of destination types.

> > Anyway, the returned result contains a `ptr` member that points to
> > the end of the string. In order to add begin()/data()/size() functions
> > basic_cstr_writer would also need to store the initial position,
> > which would increase its size a little bit. And that's the only reason
> Assuming the buffer is contiguous, begin == end - size, so there would
> be no need to store an extra pointer.

But then we need to store the size. See basic_cstr_writer implementation:

Boost list run by bdawes at, gregod at, cpdaniel at, john at