I am trying to create a STL
(or boost
) unordered_map
with boost::mulprecision
types e.g. cpp_int
but gcc
throws errors after trying to insert elements to this container.
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/unordered_map.hpp>
using namespace boost::multiprecision;
int main()
{
cpp_int z(123123123);
cpp_int x(123123123);
boost::unordered_map<cpp_int, cpp_int> data;
// line below will throw compilation errors
//data.insert(std::make_pair(z,x));
return 0;
}
Full error log is here
First of the errors:
In file included from /usr/include/boost/functional/hash/hash.hpp:529:0,
from /usr/include/boost/functional/hash.hpp:6,
from /usr/include/boost/unordered/unordered_map.hpp:20,
from /usr/include/boost/unordered_map.hpp:16,
from main.cpp:2:
/usr/include/boost/functional/hash/extensions.hpp: In instantiation of
........
main.cpp:13:34: required from here
/usr/include/boost/functional/hash/extensions.hpp:269:34: error: no matching function for call to ‘hash_value(const boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<> >&)’
return hash_value(val);
^
Is there a limitation to STL
/boost
container usage regarding boost
's multiprecision types?
I am using boost 1.54.
EDIT:
The question of which this might be a duplicate uses boost::multiprecision
's serialization support which has been added in boost 1.56 (at least according to differences in docs @1.55 and @1.56.
Also, in that question there has been no other approaches mentioned to solve this issue without serialization support in boost::multiprecision
.