• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <boost/container_hash/hash.hpp>
2 #include <vector>
3 #include <algorithm>
4 #include <iterator>
5 #include <cassert>
6 
7 //[ get_hashes
8 template <class Container>
get_hashes(Container const & x)9 std::vector<std::size_t> get_hashes(Container const& x)
10 {
11     std::vector<std::size_t> hashes;
12     std::transform(x.begin(), x.end(), std::back_inserter(hashes),
13         boost::hash<typename Container::value_type>());
14 
15     return hashes;
16 }
17 //]
18 
main()19 int main() {
20     std::vector<int> values;
21     values.push_back(10);
22     values.push_back(20);
23 
24     std::vector<std::size_t> hashes = get_hashes(values);
25     assert(hashes[0] = boost::hash<int>()(values[0]));
26     assert(hashes[1] = boost::hash<int>()(values[1]));
27 }
28