Joaquin M Lopez Munoz
Sensei
writes: My code, actually, won't find anything with equal_range, and find will return 0, although my call works in some sense, or better, the element >
I am passing DOES exist in the container. Source and output in the
following.
OK, some weird things are happening here, though I can only guess as the code you're showing is not complete. Seemingly p.equal_range(v) is returning an empty result (since the output does not emit any EQID). As for p.find(v) returning something, what's actually hapenning is that it is returning an iterator to end --this is why FIND outputs 0|0|0 when there's no such element in the container, judging from the ALL dump. This you can easily check by comparing u with p.end().
So... my wild guess is that Data::MSB is not working properly. Could you please show the code for that function? (even better, could you post a complete compilable snippet for me to play with?)
Ok, never mind, the problem is this: lookup functions take *keys*, not whole values, so instead of auto q = p.equal_range(v); you have to write auto q = p.equal_range(MSB(v)); The bug goes undetected at compile time because there's a default conversion from __uint128_t to uint64_t, but this conversion of course does not extract the MSB part, hence the run-time problems. In more usual scenarios where the key is a member of the element, the error would have been more apparent and the code wouldn't have compiled. Joaquín M López Muñoz Telefónica