From dd73b1ab64748ca623306205d0853d3ad67ed717 Mon Sep 17 00:00:00 2001 From: Thomas Spriggs Date: Tue, 17 Apr 2018 16:24:15 +0100 Subject: [PATCH] Specify default hash function of `dstringt` to STL. This provides a default hash function of `dstringt` to STL. Which means that the hash function no longer needs to be specified when declaring instances of STL containers where `dstringt` is used as the key. --- src/util/dstring.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/util/dstring.h b/src/util/dstring.h index d7b2c76409d..91c58a39f38 100644 --- a/src/util/dstring.h +++ b/src/util/dstring.h @@ -175,4 +175,18 @@ inline std::ostream &operator<<(std::ostream &out, const dstringt &a) return a.operator<<(out); } +// NOLINTNEXTLINE [allow specialisation within 'std'] +namespace std +{ +/// Default hash function of `dstringt` for use with STL containers. +template <> +struct hash // NOLINT(readability/identifiers) +{ + size_t operator()(const dstringt &dstring) const + { + return dstring.hash(); + } +}; +} + #endif // CPROVER_UTIL_DSTRING_H