Return the first element of a vector matching a predicate.

Synopsis

Declared in <util/vector.h>

template<
    typename V,
    typename L>
std::optional<V>
FindFirst(
    std::vector<V> const& vec,
    L const fnc);

Return Value

The first matching element, or std::nullopt when none match.

Parameters

Name

Description

vec

The vector to search.

fnc

The predicate invoked on each element until it returns true.

Created with MrDocs