Vcsn  2.4
Be Rational
pair.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/misc/functional.hh> // hash_combine
4 
5 namespace std
6 {
7 
8  /*-----------------.
9  | hash(pair<T>). |
10  `-----------------*/
11 
12  template <typename T1, typename T2>
13  struct hash<pair<T1, T2>>
14  {
15  size_t operator()(const pair<T1, T2>& p) const
16  {
17  size_t res = 0;
18  vcsn::hash_combine(res, p.first);
19  vcsn::hash_combine(res, p.second);
20  return res;
21  }
22  };
23 }
24 
25 
26 namespace vcsn
27 {
28 
29  /*-----------------------------.
30  | make_unordered_pair(e1, e2). |
31  `-----------------------------*/
32 
33  template <typename T>
34  auto make_unordered_pair(T&& e1, T&& e2)
35  {
36  return (e1 < e2
37  ? std::make_pair(std::forward<T&&>(e1), std::forward<T&&>(e2))
38  : std::make_pair(std::forward<T&&>(e2), std::forward<T&&>(e1)));
39  }
40 }
STL namespace.
return res
Definition: multiply.hh:398
auto make_unordered_pair(T &&e1, T &&e2)
Definition: pair.hh:34
Definition: a-star.hh:8
automaton pair(const automaton &aut, bool keep_initials)
Bridge.
Definition: pair.hh:264
size_t operator()(const pair< T1, T2 > &p) const
Definition: pair.hh:15
void hash_combine(std::size_t &seed, const T &v)
Definition: functional.hh:48