Daily bit(e) of C++ | std::search_n
Daily bit(e) of C++ #400, The algorithm for finding n consecutive elements that match a specified value: std::search_n.
The std::search_n is a simple algorithm that returns the first instance of n consecutive elements that match the provided value.
The range version conveniently returns the range representing the n consecutive elements, and both versions support a custom comparator.