Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
AlgorithmFind.h
1
// Copyright (c) Stefano Cristiano
2
// SPDX-License-Identifier: MIT
3
#pragma once
4
#include "../Foundation/Assert.h"
5
6
namespace
SC
7
{
9
namespace
Algorithms
10
{
11
14
22
template
<
typename
ForwardIterator,
typename
UnaryPredicate>
23
constexpr
ForwardIterator
findIf
(ForwardIterator first, ForwardIterator last, UnaryPredicate&& predicate)
24
{
25
SC_ASSERT_DEBUG
(first <= last);
26
for
(
auto
it = first; it != last; ++it)
27
{
28
if
(predicate(*it))
29
{
30
return
it;
31
}
32
}
33
return
last;
34
}
35
37
38
}
// namespace Algorithms
39
}
// namespace SC
SC::Algorithms::findIf
constexpr ForwardIterator findIf(ForwardIterator first, ForwardIterator last, UnaryPredicate &&predicate)
Find item satisfying the given predicate.
Definition
AlgorithmFind.h:23
SC_ASSERT_DEBUG
#define SC_ASSERT_DEBUG(e)
Assert expression e to be true.
Definition
Assert.h:82
Libraries
Algorithms
AlgorithmFind.h
Generated by
1.12.0