Merge 70bd2c9a6c9791005a57050fcf7c051fd417c80c into 297b331435d6dee09bf89c8a5ad974b01f18039b

This commit is contained in:
Teebonne 2022-12-06 10:20:37 +00:00 committed by GitHub
commit d2b88ca235
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,11 +262,13 @@ namespace std {
template <> template <>
struct hash<xlnt::cell_reference> struct hash<xlnt::cell_reference>
{ {
size_t operator()(const xlnt::cell_reference &x) const size_t operator()(const xlnt::cell_reference &x) const // using Szudzik's pairing function
{ {
static_assert(std::is_same<decltype(x.row()), std::uint32_t>::value, "this hash function expects both row and column to be 32-bit numbers"); if (x.column_index() >= x.row()) {
static_assert(std::is_same<decltype(x.column_index()), std::uint32_t>::value, "this hash function expects both row and column to be 32-bit numbers"); return hash<size_t>{}(x.column_index() * x.column_index() + x.column_index() + x.row());
return hash<std::uint64_t>{}(x.row() | static_cast<std::uint64_t>(x.column_index()) << 32); } else {
return hash<size_t>{}(x.column_index() + x.row() * x.row());
};
} }
}; };
} // namespace std } // namespace std