Skip to content

Commit dd73b1a

Browse files
committed
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.
1 parent 988b818 commit dd73b1a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/util/dstring.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,18 @@ inline std::ostream &operator<<(std::ostream &out, const dstringt &a)
175175
return a.operator<<(out);
176176
}
177177

178+
// NOLINTNEXTLINE [allow specialisation within 'std']
179+
namespace std
180+
{
181+
/// Default hash function of `dstringt` for use with STL containers.
182+
template <>
183+
struct hash<dstringt> // NOLINT(readability/identifiers)
184+
{
185+
size_t operator()(const dstringt &dstring) const
186+
{
187+
return dstring.hash();
188+
}
189+
};
190+
}
191+
178192
#endif // CPROVER_UTIL_DSTRING_H

0 commit comments

Comments
 (0)