str/maps: Add commonly used cheaper string map
These maps allow for the use of string_views to find elements so we
don't need to construct std::strings for lookups.
Change-Id: I92040b920bf8e231346bebfe9afa59f1a37b8af5
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/meson.build b/include/meson.build
index 1a1eb6f..8b8b1dd 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -15,6 +15,7 @@
'stdplus/signal.hpp',
'stdplus/str/cat.hpp',
'stdplus/str/cexpr.hpp',
+ 'stdplus/str/maps.hpp',
'stdplus/util/cexec.hpp',
'stdplus/util/string.hpp',
'stdplus/zstring.hpp',
diff --git a/include/stdplus/str/maps.hpp b/include/stdplus/str/maps.hpp
new file mode 100644
index 0000000..bc81875
--- /dev/null
+++ b/include/stdplus/str/maps.hpp
@@ -0,0 +1,23 @@
+#pragma once
+#include <string>
+#include <string_view>
+#include <unordered_map>
+#include <unordered_set>
+namespace stdplus
+{
+
+namespace detail
+{
+struct string_hash : public std::hash<std::string_view>
+{
+ using is_transparent = void;
+};
+} // namespace detail
+
+template <typename V>
+using string_umap =
+ std::unordered_map<std::string, V, detail::string_hash, std::equal_to<>>;
+using string_uset =
+ std::unordered_set<std::string, detail::string_hash, std::equal_to<>>;
+
+} // namespace stdplus