Add const qualifier to c_binary_search Sequence.

PiperOrigin-RevId: 506151912
Change-Id: I388884b0bd80ef0f8a0b3d3c7d0e1b404ddfb742
This commit is contained in:
Abseil Team
2023-01-31 16:37:12 -08:00
committed by Copybara-Service
parent dcddc54407
commit 1a38beaaaf

View File

@@ -1131,7 +1131,7 @@ c_equal_range(Sequence& sequence, const T& value, LessThan&& comp) {
// to test if any element in the sorted container contains a value equivalent to
// 'value'.
template <typename Sequence, typename T>
bool c_binary_search(Sequence&& sequence, const T& value) {
bool c_binary_search(const Sequence& sequence, const T& value) {
return std::binary_search(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
value);
@@ -1140,7 +1140,8 @@ bool c_binary_search(Sequence&& sequence, const T& value) {
// Overload of c_binary_search() for performing a `comp` comparison other than
// the default `operator<`.
template <typename Sequence, typename T, typename LessThan>
bool c_binary_search(Sequence&& sequence, const T& value, LessThan&& comp) {
bool c_binary_search(const Sequence& sequence, const T& value,
LessThan&& comp) {
return std::binary_search(container_algorithm_internal::c_begin(sequence),
container_algorithm_internal::c_end(sequence),
value, std::forward<LessThan>(comp));