after reading the remaining : you could make equivalent_iterators a class that performs the pattern matching....