Your problem might be that you don't know what a set is. A set is container class like vector, except that you cannot insert the same element twice. In your case s is a set of objects of type vector<int>. Hence, s.insert(v) inserts the vector v into the set s.
To understand how a set works you might want to read:
http://www.cplusplus.com/reference/set/set/[
^]
One of the important things is that a set keeps its elements in sorted order. When you insert a new element, a binary search is used to find the place where the element has to be inserted.
See
http://www.cplusplus.com/reference/set/set/insert/[
^] to read more about the insert operation.
Hope that made it a little clearer.
[AMENDED]
Here is a line by line description of what happens:
do {
vector<int> v;
for (int i = 0; i < N; i++)
v.push_back(myints[i]);
s.insert(v);
} while ( std::next_permutation(myints,myints+10) );
[2nd AMENDMENT]
for(auto c: s){
for (auto i: c)
cout << i << " ";
cout << endl;
}
I hope that makes it clear what the nested loops do.