Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2024-12-05 22:08:23


On 12/6/24 00:59, Ivan Matek wrote:
>
>
> On Thu, Dec 5, 2024 at 10:53 PM Andrey Semashev via Boost
> <boost_at_[hidden] <mailto:boost_at_[hidden]>> wrote:
>
> Technically, it doesn't need to be size to separate the two fields. You
> can use any kind of separator, including a fixed one (i.e. not depending
> on either of the fields it separates). I.e. instead of this:
>
>   "ab" | 2 | "c" | 1
>
> you could have this:
>
>   "ab" | separator_t{} | "c" | separator_t{}
>
> An empty sequence could simply be hashed as separator_t{}.
>
> The question is how separator_t would hash and whether it could be made
> any faster than just hashing the size. I suppose, it could be smaller
> (e.g. 1 byte of data instead of sizeof(size_t)), but I'm not sure if
> that would mean anything in terms of performance.
>
> As far as I understand that will not work. Assume separator is char 'x' 
> although it does not really matter what the value is, it is just for
> ease of writing. 
>
> now 
> "a" | "xc"
> hashes same 
> as 
> "ax" | "c"
> because both produce axxc

Yes, you're right.


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