[squid-dev] [PATCH] Extend SBufContainerJoin to have prefix and suffix arguments

Alex Rousskov rousskov at measurement-factory.com
Fri Nov 11 17:52:36 UTC 2016


On 11/11/2016 01:30 AM, Kinkie wrote:
> On Fri, Nov 11, 2016 at 5:02 AM, Amos Jeffries <squid3 at treenet.co.nz> wrote:
>> On 11/11/2016 9:28 a.m., Kinkie wrote:
>>>
>>> v4 attached.
>>>
>>
>> Does it have to take begin() and end() iterators explicitly?
>>  can we not have it take the container itself and use a for(auto &i :
>> container) loop ?
> 
> No it doesn't but it's sometimes convenient.
> My use case is the regex-compressing code. It can be reduced to (pseudocode)
> 
> join(regex-so-far, wordsList., separator=")|(", prefix="(", suffix=")")
> 
> granted, it can be done with explicit append calls but then you can't
> inline it (e.g in streams).
> 
> The code used to take the whole container, but there's a use case for
> iterating over a slice only.

Accepting iterators is standard in STL (despite being slightly
inconvenient) probably because accepting iterators covers a lot more
potential use cases.

Alex.



More information about the squid-dev mailing list