From: Jonathan Wakely Date: Wed, 24 Sep 2025 13:37:37 +0000 (+0100) Subject: libstdc++: Check feature test macro for robust_nonmodifying_seq_ops X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=08530be2593c2f1f5ce15fe3e8a2524b9f52fc6e;p=thirdparty%2Fgcc.git libstdc++: Check feature test macro for robust_nonmodifying_seq_ops 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. --- diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 78c63e79a27..b296e12cf0f 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -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= 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 diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 820091aee2d..02266807613 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -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