mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Mark non-modifying container algorithms as constexpr for C++20.
This change marks Abseil's non-modifying sequence operations including absl::linear_search and absl::c_linear_search as constexpr when building with C++20. PiperOrigin-RevId: 659812405 Change-Id: I8dc2cee873f30531b2eb8fb3da12085505a43a1a
This commit is contained in:
committed by
Copybara-Service
parent
809e5de7b9
commit
00478de3e9
@@ -53,8 +53,8 @@ using std::rotate;
|
||||
// n = (`last` - `first`) comparisons. A linear search over short containers
|
||||
// may be faster than a binary search, even when the container is sorted.
|
||||
template <typename InputIterator, typename EqualityComparable>
|
||||
bool linear_search(InputIterator first, InputIterator last,
|
||||
const EqualityComparable& value) {
|
||||
ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20 bool linear_search(
|
||||
InputIterator first, InputIterator last, const EqualityComparable& value) {
|
||||
return std::find(first, last, value) != last;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user