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.
Click to open in Compiler Explorer.
Leave a comment