libstdc++: Reduce header dependencies from PSTL headers [PR92546]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 17 Mar 2022 16:45:43 +0000 (16:45 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 18 Mar 2022 10:16:36 +0000 (10:16 +0000)
This avoids including the whole of <functional> in <algorithm>, as the
<pstl/glue_algorithm_defs.h> header only actually needs std::pair.

This also avoids including <iterator> in <pstl/utils.h>, which only
needs <type_traits>, std::bad_alloc, and std::terminate (which can be
repalced with std::__terminate). This matters less, because
<pstl/utils.h> is only included by the <pstl/*_impl.h> headers and they
all use <iterator> anyway, and are only included by <execution>.

libstdc++-v3/ChangeLog:

PR libstdc++/92546
* include/pstl/glue_algorithm_defs.h: Replace <functional> with
<bits/stl_pair.h>.
* include/pstl/utils.h: Replace <iterator> with <type_traits>.
(__pstl::__internal::__except_handler): Use std::__terminate
instead of std::terminate.
* src/c++17/fs_path.cc: Include <array>.
* testsuite/25_algorithms/adjacent_find/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/binary_search/constexpr.cc: Likewise.
* testsuite/25_algorithms/clamp/constrained.cc: Likewise.
* testsuite/25_algorithms/equal/constrained.cc: Likewise.
* testsuite/25_algorithms/for_each/constrained.cc: Likewise.
* testsuite/25_algorithms/includes/constrained.cc: Likewise.
* testsuite/25_algorithms/is_heap/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_heap_until/constexpr.cc: Likewise.
* testsuite/25_algorithms/is_permutation/constrained.cc: Include
<iterator>.
* testsuite/25_algorithms/is_sorted/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/is_sorted_until/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constexpr.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare/constrained.cc:
Likewise.
* testsuite/25_algorithms/lexicographical_compare_three_way/1.cc:
Include <array>.
* testsuite/25_algorithms/lower_bound/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/max/constrained.cc: Likewise.
* testsuite/25_algorithms/max_element/constrained.cc: Likewise.
* testsuite/25_algorithms/min/constrained.cc: Likewise.
* testsuite/25_algorithms/min_element/constrained.cc: Likewise.
* testsuite/25_algorithms/minmax_element/constrained.cc:
Likewise.
* testsuite/25_algorithms/mismatch/constexpr.cc: Likewise.
* testsuite/25_algorithms/move/93872.cc: Likewise.
* testsuite/25_algorithms/move_backward/93872.cc: Include
<iterator>.
* testsuite/25_algorithms/nth_element/constexpr.cc: Include
<functional>.
* testsuite/25_algorithms/partial_sort/constexpr.cc: Likewise.
* testsuite/25_algorithms/partial_sort_copy/constexpr.cc:
Likewise.
* testsuite/25_algorithms/search/constexpr.cc: Likewise.
* testsuite/25_algorithms/search_n/constrained.cc: Likewise.
* testsuite/25_algorithms/set_difference/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_difference/constrained.cc:
Likewise.
* testsuite/25_algorithms/set_intersection/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_intersection/constrained.cc:
Likewise.
* testsuite/25_algorithms/set_symmetric_difference/constexpr.cc:
Likewise.
* testsuite/25_algorithms/set_union/constexpr.cc: Likewise.
* testsuite/25_algorithms/set_union/constrained.cc: Likewise.
* testsuite/25_algorithms/sort/constexpr.cc: Likewise.
* testsuite/25_algorithms/sort_heap/constexpr.cc: Likewise.
* testsuite/25_algorithms/transform/constrained.cc: Likewise.
* testsuite/25_algorithms/unique/constexpr.cc: Likewise.
* testsuite/25_algorithms/unique/constrained.cc: Likewise.
* testsuite/25_algorithms/unique_copy/constexpr.cc: Likewise.
* testsuite/25_algorithms/upper_bound/constexpr.cc: Likewise.
* testsuite/std/ranges/adaptors/elements.cc: Include <vector>.
* testsuite/std/ranges/adaptors/lazy_split.cc: Likewise.
* testsuite/std/ranges/adaptors/split.cc: Likewise.

48 files changed:
libstdc++-v3/include/pstl/glue_algorithm_defs.h
libstdc++-v3/include/pstl/utils.h
libstdc++-v3/src/c++17/fs_path.cc
libstdc++-v3/testsuite/25_algorithms/adjacent_find/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/binary_search/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/clamp/constrained.cc
libstdc++-v3/testsuite/25_algorithms/equal/constrained.cc
libstdc++-v3/testsuite/25_algorithms/for_each/constrained.cc
libstdc++-v3/testsuite/25_algorithms/includes/constrained.cc
libstdc++-v3/testsuite/25_algorithms/is_heap/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/is_heap_until/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/is_permutation/constrained.cc
libstdc++-v3/testsuite/25_algorithms/is_sorted/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/is_sorted_until/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/constrained.cc
libstdc++-v3/testsuite/25_algorithms/lexicographical_compare_three_way/1.cc
libstdc++-v3/testsuite/25_algorithms/lower_bound/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/max/constrained.cc
libstdc++-v3/testsuite/25_algorithms/max_element/constrained.cc
libstdc++-v3/testsuite/25_algorithms/min/constrained.cc
libstdc++-v3/testsuite/25_algorithms/min_element/constrained.cc
libstdc++-v3/testsuite/25_algorithms/minmax_element/constrained.cc
libstdc++-v3/testsuite/25_algorithms/mismatch/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/move/93872.cc
libstdc++-v3/testsuite/25_algorithms/move_backward/93872.cc
libstdc++-v3/testsuite/25_algorithms/nth_element/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/partial_sort/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/search/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/search_n/constrained.cc
libstdc++-v3/testsuite/25_algorithms/set_difference/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/set_difference/constrained.cc
libstdc++-v3/testsuite/25_algorithms/set_intersection/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/set_intersection/constrained.cc
libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/set_union/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/set_union/constrained.cc
libstdc++-v3/testsuite/25_algorithms/sort/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/sort_heap/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/transform/constrained.cc
libstdc++-v3/testsuite/25_algorithms/unique/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/unique/constrained.cc
libstdc++-v3/testsuite/25_algorithms/unique_copy/constexpr.cc
libstdc++-v3/testsuite/25_algorithms/upper_bound/constexpr.cc
libstdc++-v3/testsuite/std/ranges/adaptors/elements.cc
libstdc++-v3/testsuite/std/ranges/adaptors/lazy_split.cc
libstdc++-v3/testsuite/std/ranges/adaptors/split.cc

index 48bc56a..cef78e2 100644 (file)
@@ -10,7 +10,7 @@
 #ifndef _PSTL_GLUE_ALGORITHM_DEFS_H
 #define _PSTL_GLUE_ALGORITHM_DEFS_H
 
-#include <functional>
+#include <bits/stl_pair.h>
 
 #include "execution_defs.h"
 
index 1711f29..0e908f1 100644 (file)
@@ -11,7 +11,7 @@
 #define _PSTL_UTILS_H
 
 #include <new>
-#include <iterator>
+#include <type_traits>
 
 namespace __pstl
 {
@@ -32,7 +32,7 @@ __except_handler(_Fp __f)
     }
     catch (...)
     {
-        std::terminate(); // Good bye according to the standard [algorithms.parallel.exceptions]
+        std::__terminate(); // Good bye according to the standard [algorithms.parallel.exceptions]
     }
 }
 
index a44fa28..0470823 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <filesystem>
 #include <algorithm>
+#include <array>
 #include <bits/stl_uninitialized.h>
 
 namespace fs = std::filesystem;
index d2a741e..772db23 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <algorithm>
 #include <array>
+#include <functional>
 
 constexpr std::array<int, 12> car{{0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 9, 11}};
 
index 41b1f67..5464dcf 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index ac03481..cab3552 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 85044a1..9ffc33f 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 1dd4312..a0ace5d 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 420ff94..a2e8e39 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do compile { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <array>
 
 // heap
index b5814a0..8d20136 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <iterator>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index e020d2e..422c1ce 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <algorithm>
 #include <array>
+#include <functional>
 
 constexpr std::array<int, 12> ca0{{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}};
 
index 708f3dd..ef904e6 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 48be0f6..16b7703 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <array>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index bba8e80..10af2b1 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 7139e37..a4291b2 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 8bec9f9..405bf96 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index bc07e3f..94ec587 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index f8785c4..df19923 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index b780126..4b0c810 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do compile { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 
 struct X
 {
index d91daf7..0ba12fe 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index b27d1c7..bee831f 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 39311f2..c80d040 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index f53827f..2e8a603 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 1db4156..b3005d9 100644 (file)
@@ -19,6 +19,7 @@
 // { dg-do run { target c++2a } }
 
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index f0fc3c3..2f0f687 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <list>
 #include <algorithm>
+#include <functional>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index 93a1c6d..30e4e41 100644 (file)
 
 #include <algorithm>
 #include <ranges>
+#include <tuple>
+#include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
-#include <tuple>
 
 namespace ranges = std::ranges;
 namespace views = ranges::views;
index e46f76d..21c0837 100644 (file)
@@ -22,6 +22,7 @@
 #include <ranges>
 #include <string>
 #include <string_view>
+#include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
 
index ca10608..a46f898 100644 (file)
@@ -22,6 +22,7 @@
 #include <ranges>
 #include <string>
 #include <string_view>
+#include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>