AK: Take the container in AK::find_value as a forwarding reference

We currently take it as a const reference, thus the return type will be
Optional<T const&>. Take the parameter as a forwarding reference, which
will allow mutable containers to return an Optional<T&>.
This commit is contained in:
Timothy Flynn 2026-01-06 07:16:59 -05:00 committed by Tim Flynn
parent b6207201d6
commit 0d938d67f8

View file

@ -38,7 +38,7 @@ requires(requires(TIterator it) { it.index(); })
}
template<IterableContainer Container, typename TUnaryPredicate>
[[nodiscard]] constexpr auto find_value(Container const& container, TUnaryPredicate&& pred)
[[nodiscard]] constexpr auto find_value(Container&& container, TUnaryPredicate&& pred)
-> Optional<decltype(*container.begin())>
{
auto it = find_if(container.begin(), container.end(), forward<TUnaryPredicate>(pred));