xieite ::find_most_consec_if ()
Defined in header <xieite/data/find_most_consec_if.hpp>
Returns a view to the longest consecutive subrange for which a predicate functor returns
true
.Declarations
#0Looks for non-overlapping subranges.template <std ::ranges ::forward_range Range ,xieite ::is_lref_invoc <bool (std ::ranges ::subrange <std ::ranges ::iterator_t <Range >>)>Pred > [[nodiscard ]]constexpr std ::ranges ::subrange <std ::ranges ::iterator_t <Range >>find_most_consec_if (Range & range ,std ::ranges ::range_size_t <Range >subrange_size ,Pred && pred = {})noexcept (xieite ::is_noex_range <Range > &&xieite ::is_noex_invoc <Pred ,bool (std ::ranges ::subrange <std ::ranges ::iterator_t <Range >>)>);
#1
template <std ::ranges ::forward_range Range ,xieite ::is_lref_invoc <bool (std ::ranges ::range_common_reference_t <Range >)>Pred =std ::identity > [[nodiscard ]]constexpr std ::ranges ::subrange <std ::ranges ::iterator_t <Range >>find_most_consec_if (Range & range ,Pred && pred = {})noexcept (xieite ::is_noex_range <Range > &&xieite ::is_noex_invoc <Pred ,bool (std ::ranges ::range_common_reference_t <Range >)>);
Example
Output:int main () {int array [] = {0 ,0 ,2 ,1 ,0 ,0 ,0 ,4 ,0 };xieite ::dump (xieite ::find_most_consec_if (array )); }
[View in Compiler Explorer][2, 1]