Commit fa588813 by Abseil Team Committed by Copybara-Service

Make `c_find_first_of`'s `options` parameter a const reference to allow temporaries.

`c_find_first_of` does not keep or return references into `options` so there's no reason to require an l-value there.

PiperOrigin-RevId: 690696332
Change-Id: Ibbabb69ba72e9506c0406f2124034a944d6899d6
parent 07fff76e
......@@ -290,7 +290,7 @@ ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
template <typename C1, typename C2>
ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
container_algorithm_internal::ContainerIter<C1>
c_find_first_of(C1& container, C2& options) {
c_find_first_of(C1& container, const C2& options) {
return std::find_first_of(container_algorithm_internal::c_begin(container),
container_algorithm_internal::c_end(container),
container_algorithm_internal::c_begin(options),
......@@ -302,7 +302,7 @@ ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
template <typename C1, typename C2, typename BinaryPredicate>
ABSL_INTERNAL_CONSTEXPR_SINCE_CXX20
container_algorithm_internal::ContainerIter<C1>
c_find_first_of(C1& container, C2& options, BinaryPredicate&& pred) {
c_find_first_of(C1& container, const C2& options, BinaryPredicate&& pred) {
return std::find_first_of(container_algorithm_internal::c_begin(container),
container_algorithm_internal::c_end(container),
container_algorithm_internal::c_begin(options),
......
......@@ -139,11 +139,13 @@ TEST_F(NonMutatingTest, FindEndWithPredicate) {
TEST_F(NonMutatingTest, FindFirstOf) {
absl::c_find_first_of(container_, sequence_);
absl::c_find_first_of(sequence_, container_);
absl::c_find_first_of(sequence_, std::array<int, 2>{1, 2});
}
TEST_F(NonMutatingTest, FindFirstOfWithPredicate) {
absl::c_find_first_of(container_, sequence_, BinPredicate);
absl::c_find_first_of(sequence_, container_, BinPredicate);
absl::c_find_first_of(sequence_, std::array<int, 2>{1, 2}, BinPredicate);
}
TEST_F(NonMutatingTest, AdjacentFind) { absl::c_adjacent_find(sequence_); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment