|
Boost : |
Subject: [boost] Array in Unordered Map
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-04-30 13:12:53
Hi,
What's the right way to get an array into an unordered map?
This one works on VC10, but GCC appears to look for the hash_value
function in namespace std.
What's the right way to do this?
Olaf
#include <array>
#include <boost/unordered_map.hpp>
namespace boost
{
template<class T, size_t N>
size_t hash_value(const std::array<T, N>& v)
{
return boost::hash_range(v.begin(), v.end());
}
}
int main()
{
boost::unordered_map<std::array<char, 20>, int> c;
c[std::array<char, 20>()] = 0;
return 0;
}
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk