MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / findIf

Function findIf

Libraries/Containers/Algorithms/AlgorithmFind.h:24–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22/// @return Iterator pointing at the found item or `last` if not found
23template <typename ForwardIterator, typename UnaryPredicate>
24constexpr ForwardIterator findIf(ForwardIterator first, ForwardIterator last, UnaryPredicate&& predicate,
25 size_t* index = nullptr)
26{
27 SC_CONTAINERS_ASSERT_DEBUG(first <= last);
28 for (auto it = first; it != last; ++it)
29 {
30 if (predicate(*it))
31 {
32 if (index)
33 {
34 *index = static_cast<size_t>(it - first);
35 }
36 return it;
37 }
38 }
39 return last;
40}
41
42/// @brief Check if the container contains a given value.
43/// @tparam Container A container with begin and end iterators

Callers 4

findFunction · 0.85
findMethod · 0.85
removeIfFunction · 0.85
containsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected