dimanche 6 décembre 2020

STD function to return the first iterator where a subsequence begins

Is there a way to return a distance between the first iterator of a sequence, which yields the start of a subsequence in case it is contained within the sequence?

I know there is std::includes which returns true if a sequence is a subsequence of another. And it can take a Compare object. My first guess was to have an object to increment a captured iterator (inside a lambda) every time the start of a subsequence is found. But then I realized that both sequences must be sorted, and a Compare object must return true on a < b.

Can this be done using the std algorithms library?

Aucun commentaire:

Enregistrer un commentaire