How to iterate through a STL set till the second last element?
问题 I want to iterate through a STL set to do operations on elements pairwise in the set. For eg. if set S={1,2,3), I need to be able to check {1,2},{2,3},{1,3}. So a very wrong C++ code for this would be as follows- set<bitset<2501> > arr; unsigned sz = arr.size(); rep(i,sz-1) { for(j=i+1;j<sz;j++) { //do processing and in my case is an OR operation if(((arr[i])|(arr[j])) == num) { cnt++; } } } I wrote the above wrong code to give you a better idea of what I want to do. A better version (should