libdballe 9.13
utils.h
1#ifndef DBALLE_DB_V7_UTILS_H
2#define DBALLE_DB_V7_UTILS_H
3
4#include <unordered_set>
5#include <wreport/varinfo.h>
6
7namespace dballe {
8namespace db {
9namespace v7 {
10
11struct IdVarcode
12{
13 int id;
14 wreport::Varcode varcode;
15
16 IdVarcode(int id, wreport::Varcode varcode) : id(id), varcode(varcode) {}
17
18 bool operator==(const IdVarcode& o) const
19 {
20 return std::tie(id, varcode) == std::tie(o.id, o.varcode);
21 }
22 bool operator!=(const IdVarcode& o) const
23 {
24 return std::tie(id, varcode) != std::tie(o.id, o.varcode);
25 }
26 bool operator<(const IdVarcode& o) const
27 {
28 return std::tie(id, varcode) < std::tie(o.id, o.varcode);
29 }
30 bool operator>(const IdVarcode& o) const
31 {
32 return std::tie(id, varcode) > std::tie(o.id, o.varcode);
33 }
34};
35
36} // namespace v7
37} // namespace db
38} // namespace dballe
39
40namespace std {
41template <> struct hash<dballe::db::v7::IdVarcode>
42{
43 typedef dballe::db::v7::IdVarcode argument_type;
44 typedef std::size_t result_type;
45 result_type operator()(argument_type const& s) const noexcept
46 {
47 result_type const h1(std::hash<int>{}(s.id));
48 result_type const h2(std::hash<wreport::Varcode>{}(s.varcode));
49 return h1 ^ (h2 << 1);
50 }
51};
52} // namespace std
53
54#endif
Definition utils.h:12