Reputation: 315
I'm trying to write a C++ program in Xcode. My code seems not to have any issues, but when I try to compile it I get the following error:
Implicit instantiation of undefined template 'std::__1::hash<std::1::pair<unsigned long, unsigned long> >'
This error would apparently be at line 1008 of LLVM's type_traits
file.
I thought it was some library error, but when I tried to compile a simple Hello World, it worked fine.
Anybody know what I'm missing?
Upvotes: 0
Views: 67
Reputation: 69912
There is no std::hash
specialisation for std::pair
(or std::tuple
). It's one of the most ridiculous features of the c++ standard and it cripples the library.
This is probably occurring because you're using a std::pair
as a key in an unordered_map
.
What you need to do is include boost: <boost/functional/hash.hpp>
and declare boost::hash<std::pair<X, Y>>
as the 3rd template parameter of your map.
Until std::hash
is fixed, it's almost useless.
Upvotes: 2