]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not declare namespace ranges in <numeric> unconditionally
authorJonathan Wakely <jwakely@redhat.com>
Tue, 15 Apr 2025 13:01:55 +0000 (14:01 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 15 Apr 2025 16:34:34 +0000 (17:34 +0100)
Move namespace ranges inside the feature test macro guard, because
'ranges' is not a reserved name before C++20.

libstdc++-v3/ChangeLog:

* include/std/numeric (ranges): Only declare namespace for C++23
and later.
(ranges::iota_result): Fix indentation.
* testsuite/17_intro/names.cc: Check ranges is not used as an
identifier before C++20.

libstdc++-v3/include/std/numeric
libstdc++-v3/testsuite/17_intro/names.cc

index 4d36fcd36d98497984c6be4504c238728f923790..490963ee46d1d9d580cd1d0bd32f606b931fc486 100644 (file)
@@ -732,12 +732,11 @@ namespace __detail
   /// @} group numeric_ops
 #endif // C++17
 
+#if __glibcxx_ranges_iota >= 202202L // C++ >= 23
 namespace ranges
 {
-#if __glibcxx_ranges_iota >= 202202L // C++ >= 23
-
   template<typename _Out, typename _Tp>
-  using iota_result = out_value_result<_Out, _Tp>;
+    using iota_result = out_value_result<_Out, _Tp>;
 
   struct __iota_fn
   {
@@ -762,9 +761,8 @@ namespace ranges
   };
 
   inline constexpr __iota_fn iota{};
-
-#endif // __glibcxx_ranges_iota
 } // namespace ranges
+#endif // __glibcxx_ranges_iota
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
index 4458325e52b30126df78f9fe874ff90d88e3416e..f67818db425fe278810b0e7c01b6a0fa03e4bab3 100644 (file)
 #define try_emplace (
 #endif
 
+#if __cplusplus < 202002L
+#define ranges (
+#endif
+
 // These clash with newlib so don't use them.
 # define __lockable            cannot be used as an identifier
 # define __null_sentinel       cannot be used as an identifier