Subject: [Boost-bugs] [Boost C++ Libraries] #12171: boost::multiprecision should provide a hash function
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-05-02 09:46:39
#12171: boost::multiprecision should provide a hash function
-------------------------------------------------+-------------------------
Reporter: Tassilo Glander <tassilo.glander@â¦> | Owner: johnmaddock
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component:
Version: Boost 1.60.0 | multiprecision
Keywords: | Severity:
| Optimization
-------------------------------------------------+-------------------------
For boost::multiprecision types to be used in std::unordered_map etc.,
they need to provide a hash function. A straightforward way on cpp_int
would be to use the internal limbs like:
size_t getHashCode() const
{
std::size_t result = _number.sign();
std::size_t size = _number.backend().size();
auto p = _number.backend().limbs();
for (std::size_t i = 0; i < size; ++i) {
boost::hash_combine(result, *p);
++p;
}
return result;
}
and the accompanying hash functor.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12171> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC