Try again to fix hash<fbstring> namespacing
[folly.git] / folly / String.h
index bea17b7261953ba91a15648ba4ba183273281a5b..90f9c7393857a13bc7dde1dea85f2eaa9ecf3f60 100644 (file)
@@ -495,19 +495,24 @@ std::string join(const Delim& delimiter,
 
 } // namespace folly
 
-// Hash functions for string and fbstring usable with e.g. hash_map
+// Hash functions to make std::string usable with e.g. hash_map
 //
-// We let Boost pick the namespace here for us, since it has logic to do the
-// right thing based on the C++ standard library implementation being used.
-namespace BOOST_STD_EXTENSION_NAMESPACE {
+// Handle interaction with different C++ standard libraries, which
+// expect these types to be in different namespaces.
+namespace std {
 
 template <class C>
-struct hash<folly::basic_fbstring<C> > : private hash<const C*> {
-  size_t operator()(const folly::basic_fbstring<C> & s) const {
+struct hash<std::basic_string<C> > : private hash<const C*> {
+  size_t operator()(const std::basic_string<C> & s) const {
     return hash<const C*>::operator()(s.c_str());
   }
 };
 
+}
+
+#if defined(_GLIBCXX_SYMVER) && !defined(__BIONIC__)
+namespace __gnu_cxx {
+
 template <class C>
 struct hash<std::basic_string<C> > : private hash<const C*> {
   size_t operator()(const std::basic_string<C> & s) const {
@@ -516,6 +521,7 @@ struct hash<std::basic_string<C> > : private hash<const C*> {
 };
 
 }
+#endif
 
 // Hook into boost's type traits
 namespace boost {