You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by dr...@apache.org on 2017/10/20 14:51:44 UTC
[trafficserver] branch master updated: add string_view hash operator
This is an automated email from the ASF dual-hosted git repository.
dragon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 0cfa80e add string_view hash operator
0cfa80e is described below
commit 0cfa80e3f884a460d010dd64a4eaee588ed784b9
Author: Jason Kenny <jk...@oath.com>
AuthorDate: Thu Oct 19 14:20:40 2017 -0500
add string_view hash operator
clang-format
---
lib/ts/string_view.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/ts/string_view.h b/lib/ts/string_view.h
index b68e56d..89e3ff6 100644
--- a/lib/ts/string_view.h
+++ b/lib/ts/string_view.h
@@ -1212,6 +1212,19 @@ using string_view = basic_string_view<char>;
} // namespace ts
+namespace std
+{
+template <class _Type, class _Traits> struct hash<ts::basic_string_view<_Type, _Traits>> {
+ using string_type = ts::basic_string_view<_Type, _Traits>;
+
+ size_t
+ operator()(string_type const &x) const
+ {
+ return hash<typename string_type::const_pointer>()(x.data());
+ }
+};
+}
+
/// Literal suffix for string_view.
/// @note This enables @c string_view literals from C++ string literals in @c constexpr contexts, which
/// is not the case for the character pointer constructor.
@@ -1221,6 +1234,7 @@ constexpr ts::string_view operator"" _sv(const char *str, size_t len) noexcept
return ts::string_view(str, len);
}
+//////////////////////////////////////////////////////////////////////////////////////
// TS local extensions, not dependent on our local implementation of std::string_view.
/// Check for prefix.
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].