summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-10-19 17:18:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-10-23 08:15:35 +0200
commit87a9979c8938b800aab6e35903d60d24892e7f2e (patch)
tree6beb01f22537e63df24c023ab65d391a7bee0cf6 /include/rtl
parentd76c4e5c9aaf8bd27ec97679bcaeba5b18aca493 (diff)
overload std::hash for OUString and OString
no need to explicitly specify it anymore Change-Id: I6ad9259cce77201fdd75152533f5151aae83e9ec Reviewed-on: https://gerrit.libreoffice.org/43567 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/string.hxx21
-rw-r--r--include/rtl/ustring.hxx21
2 files changed, 42 insertions, 0 deletions
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index c116250aa396..6ea56c3f48e2 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -1912,6 +1912,27 @@ using ::rtl::OStringHash;
using ::rtl::OStringLiteral;
#endif
+/// @cond INTERNAL
+/**
+ Make OString hashable by default for use in STL containers.
+
+ @since LibreOffice 6.0
+*/
+#if defined LIBO_INTERNAL_ONLY
+namespace std {
+
+template<>
+struct hash<::rtl::OString>
+{
+ std::size_t operator()(::rtl::OString const & s) const
+ { return std::size_t(s.hashCode()); }
+};
+
+}
+
+#endif
+/// @endcond
+
#endif // INCLUDED_RTL_STRING_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index c6ce9a73eb99..96afdc438c83 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -3703,6 +3703,27 @@ using ::rtl::OUStringLiteral;
using ::rtl::OUStringLiteral1;
#endif
+/// @cond INTERNAL
+/**
+ Make OUString hashable by default for use in STL containers.
+
+ @since LibreOffice 6.0
+*/
+#if defined LIBO_INTERNAL_ONLY
+namespace std {
+
+template<>
+struct hash<::rtl::OUString>
+{
+ std::size_t operator()(::rtl::OUString const & s) const
+ { return std::size_t(s.hashCode()); }
+};
+
+}
+
+#endif
+/// @endcond
+
#endif /* _RTL_USTRING_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */