Boost logo

Boost Users :

Subject: Re: [Boost-users] A library for "string chains"?
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2014-08-18 04:09:31


>> On Aug 18, 2014, at 2:46 AM, Jan Herrmann <jherrmann79_at_[hidden]> wrote:
>>
>> On 15.08.2014 23:52, Richard wrote:
>> [Please do not mail me a copy of your followup]
>>
>> Jan Herrmann <jherrmann79_at_[hidden]> spake the secret code
>> <53EDB252.9060903_at_[hidden]> thusly:
>>
>>>> On 14.08.2014 03:37, Richard wrote:
>>>> Now the question remains... is there something that already exists
>>>> that provides a string_view from a vector of string_ref's?
>>>
>>> Range with
>>> http://www.boost.org/doc/libs/1_56_0/libs/range/doc/html/range/reference/utilities/join.html
>>> could help.
>>
>> Hmm... looks interesting. Obviously that could be used to get a
>> single iterator over two string_ref's.
>>
>> If I have a chain of string_ref's r1...rN, it looks like I'd have to do:
>>
>> join(r1, join(r2, join(r3, join(r4, ..., join(rN-1, rN) ...)))
>>
>> Which doesn't look promising, but I'll give it a go.
>
> I think you will loose an O(1) indexed access but that might not be a problem. To join a container of string_refs std::accumulate could help.

Believe each join type is unique, and type erasure on containers is usually non-performant, so the best you could do is fusion::accumulate - if your sequences were compile-time, which they are clearly no).

The classic data structure for this stuff is a rope, but I don't know of a rope that refers to an outside buffer... :-(

Cheers
Gordon


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