mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
AK: Add nodiscard
attribute to Find functions
This commit is contained in:
parent
ef4b98be52
commit
c860d8f5be
Notes:
sideshowbarker
2024-07-17 09:45:12 +09:00
Author: https://github.com/ldm5180 Commit: https://github.com/SerenityOS/serenity/commit/c860d8f5be Pull-request: https://github.com/SerenityOS/serenity/pull/14395 Reviewed-by: https://github.com/linusg
1 changed files with 3 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
|||
namespace AK {
|
||||
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename TUnaryPredicate>
|
||||
constexpr TIterator find_if(TIterator first, TEndIterator last, TUnaryPredicate&& pred)
|
||||
[[nodiscard]] constexpr TIterator find_if(TIterator first, TEndIterator last, TUnaryPredicate&& pred)
|
||||
{
|
||||
for (; first != last; ++first) {
|
||||
if (pred(*first)) {
|
||||
|
@ -24,13 +24,13 @@ constexpr TIterator find_if(TIterator first, TEndIterator last, TUnaryPredicate&
|
|||
}
|
||||
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename T>
|
||||
constexpr TIterator find(TIterator first, TEndIterator last, T const& value)
|
||||
[[nodiscard]] constexpr TIterator find(TIterator first, TEndIterator last, T const& value)
|
||||
{
|
||||
return find_if(first, last, [&](auto const& v) { return Traits<T>::equals(value, v); });
|
||||
}
|
||||
|
||||
template<typename TEndIterator, IteratorPairWith<TEndIterator> TIterator, typename T>
|
||||
constexpr size_t find_index(TIterator first, TEndIterator last, T const& value) requires(requires(TIterator it) { it.index(); })
|
||||
[[nodiscard]] constexpr size_t find_index(TIterator first, TEndIterator last, T const& value) requires(requires(TIterator it) { it.index(); })
|
||||
{
|
||||
return find_if(first, last, [&](auto const& v) { return Traits<T>::equals(value, v); }).index();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue