summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-17 01:24:37 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2011-02-17 01:24:37 +0000
commit12eb80e3e611445be20f3197a1365c4bfa5609b8 (patch)
tree6de2ec713ac4218c2b5da837f86a5c1ff8bae243 /libstdc++-v3/include
parentb455b8b87d29c4885c9383773a5240d11053531e (diff)
downloadgcc-12eb80e3e611445be20f3197a1365c4bfa5609b8.tar.gz
2011-02-16 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/47773 * include/ext/vstring.h (hash<__gnu_cxx::__vstring>, hash<__gnu_cxx::__wvstring>, hash<__gnu_cxx::__u16vstring>, hash<__gnu_cxx::__u32vstring>): Add. * testsuite/ext/vstring/hash/char/1.cc: New. * testsuite/ext/vstring/hash/wchar_t/1.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/ext/vstring.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h
index 46959787c2d..6e43e2b0818 100644
--- a/libstdc++-v3/include/ext/vstring.h
+++ b/libstdc++-v3/include/ext/vstring.h
@@ -2731,6 +2731,66 @@ _GLIBCXX_END_NAMESPACE_VERSION
#endif
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+
+#include <bits/functional_hash.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /// std::hash specialization for __vstring.
+ template<>
+ struct hash<__gnu_cxx::__vstring>
+ : public __hash_base<size_t, __gnu_cxx::__vstring>
+ {
+ size_t
+ operator()(const __gnu_cxx::__vstring& __s) const
+ { return std::_Hash_impl::hash(__s.data(), __s.length()); }
+ };
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ /// std::hash specialization for __wvstring.
+ template<>
+ struct hash<__gnu_cxx::__wvstring>
+ : public __hash_base<size_t, __gnu_cxx::__wvstring>
+ {
+ size_t
+ operator()(const __gnu_cxx::__wvstring& __s) const
+ { return std::_Hash_impl::hash(__s.data(),
+ __s.length() * sizeof(wchar_t)); }
+ };
+#endif
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+ /// std::hash specialization for __u16vstring.
+ template<>
+ struct hash<__gnu_cxx::__u16vstring>
+ : public __hash_base<size_t, __gnu_cxx::__u16vstring>
+ {
+ size_t
+ operator()(const __gnu_cxx::__u16vstring& __s) const
+ { return std::_Hash_impl::hash(__s.data(),
+ __s.length() * sizeof(char16_t)); }
+ };
+
+ /// std::hash specialization for __u32vstring.
+ template<>
+ struct hash<__gnu_cxx::__u32vstring>
+ : public __hash_base<size_t, __gnu_cxx::__u32vstring>
+ {
+ size_t
+ operator()(const __gnu_cxx::__u32vstring& __s) const
+ { return std::_Hash_impl::hash(__s.data(),
+ __s.length() * sizeof(char32_t)); }
+ };
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* __GXX_EXPERIMENTAL_CXX0X__ */
+
#include "vstring.tcc"
#endif /* _VSTRING_H */