The P0024R2 paper that added the parallel algorithms to C++17 also added
some new non-parallel algorithms, e.g. std::for_each_n, std::reduce,
std::exclusive_scan etc.
We cannot guard the definitions of those non-parallel algos with a check
for the __cpp_lib_parallel_algorithm (or __glibcxx_parallel_algorithm)
macro that corresponds to P0024R2 because that is only defined for
hosted, and the non-parallel algos are freestanding.
Add comments to the #if lines explaining why they check __cplusplus
directly instead of using a feature test macro.
libstdc++-v3/ChangeLog:
* include/bits/stl_algo.h (for_each_n): Add comment about
preprocessor check not using a feature test macro.
* include/std/numeric (reduce, transform_reduce, exclusive_scan)
(inclusive_scan, transform_exclusive_scan)
(transform_inclusive_scan): Likewise.
---
This is mostly so that next time I noticed these __cplusplus checks I'm
not tempted to replace them with __glibcxx_parallel_algorithm checks
instead.
Pushed to trunk.
libstdc++-v3/include/bits/stl_algo.h | 2 +-
libstdc++-v3/include/std/numeric | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libstdc++-v3/include/bits/stl_algo.h
b/libstdc++-v3/include/bits/stl_algo.h
index 6a9e133ce955..f7c4053eab44 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -3847,7 +3847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
return __f; // N.B. [alg.foreach] says std::move(f) but it's redundant.
}
-#if __cplusplus >= 201703L
+#if __cplusplus >= 201703L // __cpp_lib_parallel_algorithm but not hosted-only
/**
* @brief Apply a function to every element of a sequence.
* @ingroup non_mutating_algorithms
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index f83e25550857..df3d466f7356 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -266,7 +266,7 @@ namespace __detail
}
#endif // __cpp_lib_interpolate
-#if __cplusplus >= 201703L
+#if __cplusplus >= 201703L // __cpp_lib_parallel_algorithm but not hosted-only
/// @addtogroup numeric_ops
/// @{
--
2.56.1