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.
This commit is contained in:
Jonathan Wakely
2025-09-24 14:37:37 +01:00
committed by Jonathan Wakely
parent 0959f0e0ce
commit 08530be259
2 changed files with 4 additions and 4 deletions

View 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>

View 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