BPHash
General object hashing library for C++
test_stl.cpp
Go to the documentation of this file.
1 /*! \file
2  * \brief Testing of std::hash replacement
3  */
4 
5 /* Copyright (c) 2016 Benjamin Pritchard <ben@bennyp.org>
6  * This file is part of the BPHash project, which is released
7  * under the BSD 3-clause license. See the LICENSE file for details
8  */
9 
10 #include "bphash/Hasher.hpp"
11 #include "bphash/StdHash.hpp"
12 #include "bphash/types/All.hpp"
13 
14 #include <iostream>
15 #include <string>
16 
17 using namespace bphash;
18 
19 int main(void)
20 {
21  typedef std::pair<int, double> key_type;
22 
23  std::unordered_set<key_type, bphash::StdHash<key_type>> us;
24  us.emplace(key_type{0, 10.1});
25  us.emplace(key_type{1, 10.2});
26  us.emplace(key_type{2, 10.3});
27  us.emplace(key_type{3, 10.4});
28  us.emplace(key_type{4, 10.5});
29  us.emplace(key_type{5, 10.5});
30  us.emplace(key_type{5, 10.5});
31 
32  //! \todo Don't forget to test vector<bool>
33 
34  std::cout << "\n";
35  std::cout << "Elements in unordered set: " << us.size() << "\n";
36  for(const auto & it : us)
37  std::cout << " -> (" << it.first << " " << it.second << ")\n";
38 
39  return 0;
40 }
41 
A class that hashes objects (header)
A class that can be used in place of std::hash.
int main(void)
Definition: test_stl.cpp:19
A convenience header that includes all the types supported by bphash.