Files

21 lines
639 B
C++
Raw Permalink Normal View History

2019-03-30 14:10:57 -04:00
#include "hash_std.h" // defines Person with std::hash specialization
2019-03-30 20:50:47 -04:00
#include <iostream>
2019-03-30 14:10:57 -04:00
#include <parallel_hashmap/phmap.h>
int main()
{
// As we have defined a specialization of std::hash() for Person,
// we can now create sparse_hash_set or sparse_hash_map of Persons
// ----------------------------------------------------------------
phmap::flat_hash_set<Person> persons =
2019-03-31 10:59:35 -04:00
{ { "John", "Mitchell", 35 },
{ "Jane", "Smith", 32 },
{ "Jane", "Smith", 30 },
2019-03-30 14:10:57 -04:00
};
for (auto& p: persons)
2019-03-31 10:59:35 -04:00
std::cout << p._first << ' ' << p._last << " (" << p._age << ")" << '\n';
2019-03-30 14:10:57 -04:00
}