diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2025-04-06 01:44:18 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2025-04-24 16:53:44 +0000 |
commit | 22c008cc523fcc12fe03a244a61d327e06df35bf (patch) | |
tree | 9e42b8db30c5b0a76203a29b8e2d247dc853920c | |
parent | 7f52357ff7f1132dbefa6346c9e23606831cb29b (diff) | |
download | gcc-22c008cc523fcc12fe03a244a61d327e06df35bf.zip gcc-22c008cc523fcc12fe03a244a61d327e06df35bf.tar.gz gcc-22c008cc523fcc12fe03a244a61d327e06df35bf.tar.bz2 |
Add hash function for Identifiers
gcc/rust/ChangeLog:
* ast/rust-ast.h: Add hash function.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 5f302bc..9581dd5 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -2102,6 +2102,19 @@ template <> struct less<Rust::Identifier> return lhs.as_string () < rhs.as_string (); } }; + +template <> struct hash<Rust::Identifier> +{ + std::size_t operator() (const Rust::Identifier &k) const + { + using std::hash; + using std::size_t; + using std::string; + + return hash<string> () (k.as_string ()) ^ (hash<int> () (k.get_locus ())); + } +}; + } // namespace std #endif |