In cases where you don't know which class you're iterating over (because it's a template argument), you should use an iterator because not every class that provides an iterator also provides []
(and not every class that does provide []
, provides one which works in O(1) time). So by using iterator you'll make sure that the function will work with as many classes as possible (though not with C arrays).
In this specific case, I see no reason to prefer one over the other except personal preference or maybe premature optimization.