carl  24.04
Computer ARithmetic Library
hash.h
Go to the documentation of this file.
1 /**
2  * @file adaption_gmpxx/hash.h
3  * @ingroup gmpxx
4  * @author Sebastian Junges
5  * @author Florian Corzilius
6  *
7  */
8 
9 #pragma once
10 
11 #ifndef INCLUDED_FROM_NUMBERS_H
12 static_assert(false, "This file may only be included indirectly by numbers.h");
13 #endif
14 
15 #include <carl-common/util/hash.h>
16 #include "include.h"
17 
18 
19 #include <cstddef>
20 #include <functional>
21 
22 namespace std {
23 
24 template<>
25 struct hash<mpz_class> {
26  std::size_t operator()(const mpz_class& z) const {
27  return z.get_ui();
28  }
29 };
30 
31 template<>
32 struct hash<mpq_class> {
33  std::size_t operator()(const mpq_class& q) const {
34  return carl::hash_all(q.get_num(), q.get_den());
35  }
36 };
37 
38 }
std::size_t hash_all(Args &&... args)
Hashes an arbitrary number of values.
Definition: hash.h:71
std::size_t operator()(const mpz_class &z) const
Definition: hash.h:26
std::size_t operator()(const mpq_class &q) const
Definition: hash.h:33