| 22 | /// @return Iterator pointing at the found item or `last` if not found |
| 23 | template <typename ForwardIterator, typename UnaryPredicate> |
| 24 | constexpr 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 |