libstdc++: Refactor includes for unordered containers
authorJonathan Wakely <jwakely@redhat.com>
Tue, 24 May 2022 11:17:01 +0000 (12:17 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 26 May 2022 09:44:45 +0000 (10:44 +0100)
This moves some #include directives to the relevant place. For example,
<bits/hashtable_policy.h> needs <bits/stl_pair.h> so should include it
directly instead of relying on <unordered_map> and <unordered_set> to do
so first.

libstdc++-v3/ChangeLog:

* include/bits/functional_hash.h (__is_fast_hash): Add doxygen
comment.
* include/bits/hashtable.h: Do not include <bits/stl_function.h>
here.
* include/bits/hashtable_policy.h: Include <bits/stl_pair.h> and
<bits/functional_hash.h>.
* include/bits/unordered_map.h: Include required headers.
* include/bits/unordered_set.h: Likewise.
* include/std/unordered_map: Do not include headers for indirect
dependencies.
* include/std/unordered_set: Likewise.

libstdc++-v3/include/bits/functional_hash.h
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/include/bits/unordered_map.h
libstdc++-v3/include/bits/unordered_set.h
libstdc++-v3/include/std/unordered_map
libstdc++-v3/include/std/unordered_set

index c00113e..292c0ee 100644 (file)
@@ -280,10 +280,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// @} group hashes
 
-  // Hint about performance of hash functor. If not fast the hash-based
-  // containers will cache the hash code.
-  // Default behavior is to consider that hashers are fast unless specified
-  // otherwise.
+  /** Hint about performance of hash functions.
+   *
+   * If a given hash function object is not fast, the hash-based containers
+   * will cache the hash code.
+   * The default behavior is to consider that hashers are fast unless specified
+   * otherwise.
+   *
+   * Users can specialize this for their own hash functions in order to force
+   * caching of hash codes in unordered containers. Specializing this trait
+   * affects the ABI of the unordered containers, so use it carefully.
+   */
   template<typename _Hash>
     struct __is_fast_hash : public std::true_type
     { };
index edc151e..29ec119 100644 (file)
 
 #include <bits/hashtable_policy.h>
 #include <bits/enable_special_members.h>
+#include <bits/stl_function.h> // __has_is_transparent_t
 #if __cplusplus > 201402L
 # include <bits/node_handle.h>
 #endif
-#include <bits/functional_hash.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
index 799c3e9..1a25970 100644 (file)
@@ -32,7 +32,9 @@
 #define _HASHTABLE_POLICY_H 1
 
 #include <tuple>               // for std::tuple, std::forward_as_tuple
+#include <bits/functional_hash.h> // for __is_fast_hash
 #include <bits/stl_algobase.h> // for std::min, std::is_permutation.
+#include <bits/stl_pair.h>     // for std::pair
 #include <ext/aligned_buffer.h>        // for __gnu_cxx::__aligned_buffer
 #include <ext/alloc_traits.h>  // for std::__alloc_rebind
 #include <ext/numeric_traits.h>        // for __gnu_cxx::__int_traits
index d5edfde..5a3e6f6 100644 (file)
 #ifndef _UNORDERED_MAP_H
 #define _UNORDERED_MAP_H
 
+#include <bits/hashtable.h>
+#include <bits/allocator.h>
+#include <bits/functional_hash.h> // hash
+#include <bits/stl_function.h>    // equal_to
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
index d2fa2c5..740bbaf 100644 (file)
 #ifndef _UNORDERED_SET_H
 #define _UNORDERED_SET_H
 
+#include <bits/hashtable.h>
+#include <bits/allocator.h>
+#include <bits/functional_hash.h> // hash
+#include <bits/stl_function.h>    // equal_to
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
index e13bb9a..b50ec2a 100644 (file)
 # include <bits/c++0x_warning.h>
 #else
 
-#include <type_traits>
 #include <initializer_list>
-#include <bits/allocator.h>
-#include <ext/alloc_traits.h>
-#include <ext/aligned_buffer.h>
-#include <bits/stl_pair.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
-#include <bits/functional_hash.h>
-#include <bits/hashtable.h>
 #include <bits/unordered_map.h>
 #include <bits/range_access.h>
 #include <bits/erase_if.h>
index 8b66571..edaa517 100644 (file)
 # include <bits/c++0x_warning.h>
 #else
 
-#include <type_traits>
 #include <initializer_list>
-#include <bits/allocator.h>
-#include <ext/alloc_traits.h>
-#include <ext/aligned_buffer.h>
-#include <bits/stl_pair.h>
-#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
-#include <bits/functional_hash.h>
-#include <bits/hashtable.h>
 #include <bits/unordered_set.h>
 #include <bits/range_access.h>
 #include <bits/erase_if.h>