What's the best way to iterate over all pairs of elements in std container like std::list
, std::set
, std::vector
, etc.?
Basically to do the equivalent of this, but with iterators:
for (int i = 0; i < A.size()-1; i++)
for(int j = i+1; j < A.size(); j++)
cout << A[i] << A[j] << endl;