]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Check feature test macro for robust_nonmodifying_seq_ops
authorJonathan Wakely <jwakely@redhat.com>
Wed, 24 Sep 2025 13:37:37 +0000 (14:37 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 25 Sep 2025 13:52:25 +0000 (14:52 +0100)
We should check the relevant feature test macro instead of just the
value of __cplusplus.

Also add a comment explaining why the __cplusplus check guarding
__sample *can't* be changed to check __glibcxx_sample (because __sample
is also used in C++14 by std::experimental::sample, not only by C++17
std::sample).

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h: Check robust_nonmodifying_seq_ops
feature test macro instead of checking __cplusplus value. Add
comment to another __cplusplus check.
* include/bits/stl_algobase.h: Add comment to #endif.

libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/include/bits/stl_algobase.h

index 78c63e79a279e09aae71fd5b014ab98bbaa10221..b296e12cf0f82fdd9cd91b41e11cb8e898367f4c 100644 (file)
@@ -3516,7 +3516,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
                                   __gnu_cxx::__ops::__iter_comp_iter(__pred));
     }
 
-#if __cplusplus > 201103L
+#if __glibcxx_robust_nonmodifying_seq_ops // C++ >= 14
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
   template<typename _ForwardIterator1, typename _ForwardIterator2,
@@ -3635,7 +3635,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
       return std::__is_permutation(__first1, __last1, __first2, __last2,
                                   __gnu_cxx::__ops::__iter_comp_iter(__pred));
     }
-#endif // C++14
+#endif // __glibcxx_robust_nonmodifying_seq_ops
 
 #ifdef  __glibcxx_clamp // C++ >= 17
   /**
@@ -5828,7 +5828,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
     }
 #endif // C++11
 
-#if __cplusplus >= 201402L
+#if __cplusplus >= 201402L // C++17 std::sample and C++14 experimental::sample
   /// Reservoir sampling algorithm.
   template<typename _InputIterator, typename _RandomAccessIterator,
            typename _Size, typename _UniformRandomBitGenerator>
index 820091aee2dc3cbc22dbaa9362261f5a93fe41ce..0226680761386fdc4cadb4bffa19b597ab2edb4c 100644 (file)
@@ -2090,7 +2090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
       return _GLIBCXX_STD_A::__mismatch(__first1, __last1, __first2, __last2,
                             __gnu_cxx::__ops::__iter_comp_iter(__binary_pred));
     }
-#endif
+#endif // __glibcxx_robust_nonmodifying_seq_ops
 
 _GLIBCXX_END_NAMESPACE_ALGO