mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:24:58 +00:00
AK: Use Iterator's trait when comparing a value
It's not needed, from what I can gather, but I changed it just for the correctness sake.
This commit is contained in:
parent
e575ee4462
commit
9663ccff77
1 changed files with 6 additions and 8 deletions
14
AK/Find.h
14
AK/Find.h
|
@ -23,19 +23,17 @@ template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typena
|
|||
return last;
|
||||
}
|
||||
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename T>
|
||||
[[nodiscard]] constexpr TIterator find(TIterator first, TEndIterator last, T const& value)
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename V>
|
||||
[[nodiscard]] constexpr TIterator find(TIterator first, TEndIterator last, V const& value)
|
||||
{
|
||||
// FIXME: Use the iterator's trait type, and swap arguments in equals call.
|
||||
return find_if(first, last, [&](auto const& v) { return Traits<T>::equals(value, v); });
|
||||
return find_if(first, last, [&]<typename T>(T const& entry) { return Traits<T>::equals(entry, value); });
|
||||
}
|
||||
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename T>
|
||||
[[nodiscard]] constexpr size_t find_index(TIterator first, TEndIterator last, T const& value)
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename V>
|
||||
[[nodiscard]] constexpr size_t find_index(TIterator first, TEndIterator last, V const& value)
|
||||
requires(requires(TIterator it) { it.index(); })
|
||||
{
|
||||
// FIXME: Use the iterator's trait type, and swap arguments in equals call.
|
||||
return find_if(first, last, [&](auto const& v) { return Traits<T>::equals(value, v); }).index();
|
||||
return find_if(first, last, [&]<typename T>(T const& entry) { return Traits<T>::equals(entry, value); }).index();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue