<locale>
: std::collate_byname<_Elem>::hash()
yields different hashes for strings that collate the same
#5212
Labels
bug
Something isn't working
[locale.collate.virtuals]/3 specifies that
collate<_Elem>::do_hash()
returns the same hash for all strings that collate the same. However,collate_byname<_Elem>::(do_)hash()
does not produce such hashes for non-C locales.Test case
prints
Godbolt link
Expected result
This should print
Additional remarks
For non-C locales, I think the hash function should essentially do:
return hash(transform(_First, _Last));
Alternatively,
LCMapStringA/W/Ex
withLCMAP_HASH
could be used. It's probably faster, butLCMAP_HASH
is not guaranteed to produce the same hash for all strings that collate the same according to the API documentation, so it seems this also wouldn't fully conform to [locale.collate.virtuals]/3.The text was updated successfully, but these errors were encountered: