diff --git a/include/xlnt/cell/cell_reference.hpp b/include/xlnt/cell/cell_reference.hpp index c8efcb4b3..d551b6ab3 100644 --- a/include/xlnt/cell/cell_reference.hpp +++ b/include/xlnt/cell/cell_reference.hpp @@ -262,11 +262,13 @@ namespace std { template <> struct hash { - 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::value, "this hash function expects both row and column to be 32-bit numbers"); - static_assert(std::is_same::value, "this hash function expects both row and column to be 32-bit numbers"); - return hash{}(x.row() | static_cast(x.column_index()) << 32); + if (x.column_index() >= x.row()) { + return hash{}(x.column_index() * x.column_index() + x.column_index() + x.row()); + } else { + return hash{}(x.column_index() + x.row() * x.row()); + }; } }; } // namespace std