aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/dtc/string.hh
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/dtc/string.hh')
-rw-r--r--usr.bin/dtc/string.hh17
1 files changed, 17 insertions, 0 deletions
diff --git a/usr.bin/dtc/string.hh b/usr.bin/dtc/string.hh
index 45bc4fda71c5..f6acc1b2e8a4 100644
--- a/usr.bin/dtc/string.hh
+++ b/usr.bin/dtc/string.hh
@@ -33,6 +33,8 @@
#ifndef _STRING_HH_
#define _STRING_HH_
#include "input_buffer.hh"
+#include <string>
+#include <functional>
namespace dtc
{
@@ -48,6 +50,7 @@ namespace dtc
*/
class string
{
+ friend std::hash<string>;
/** Start address. Contained within the mmap()'d input file and not
* owned by this object. */
const char *start;
@@ -143,5 +146,19 @@ class string
};
} // namespace dtc
+namespace std
+{
+ template<>
+ struct hash<dtc::string>
+ {
+ std::size_t operator()(dtc::string const& s) const
+ {
+ std::string str(s.start, s.length);
+ std::hash<std::string> h;
+ return h(str);
+ }
+ };
+}
+
#endif // !_STRING_HH_