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:
parent
b6207201d6
commit
0d938d67f8
1 changed files with 1 additions and 1 deletions
|
|
@ -38,7 +38,7 @@ requires(requires(TIterator it) { it.index(); })
|
||||||
}
|
}
|
||||||
|
|
||||||
template<IterableContainer Container, typename TUnaryPredicate>
|
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())>
|
-> Optional<decltype(*container.begin())>
|
||||||
{
|
{
|
||||||
auto it = find_if(container.begin(), container.end(), forward<TUnaryPredicate>(pred));
|
auto it = find_if(container.begin(), container.end(), forward<TUnaryPredicate>(pred));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue