“C++11 idioms” include a preference for immutability, which leads to natural factorings. You don’t have to worry about things like iterator invalidation that way.
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
template<class T>
void print(const T& v) {
copy(begin(v), end(v), ostream_iterator<string>(cout, "\n"));
}
int main(int argc, char** argv) {
vector<string> v{"Hello", "there"};
print(v);
}
Also, Haskell is only so safe—at work we’ve taken to rejecting non-total functions in review, because they cause more hassle than they’re worth. By non-total, I refer more to “error” than non-termination, of course.