fork download
  1. #include <iostream>
  2. #include <list>
  3. using namespace std;
  4.  
  5. int main() {
  6. list<int> numbers;
  7. for (int i = 0; i < 10; ++i) {
  8. numbers.push_back(i);
  9. }
  10.  
  11. numbers.unique([](int a, int b){
  12. cout << a << ", " << b << endl;
  13. return a == b;
  14. });
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
0, 1
1, 2
2, 3
3, 4
4, 5
5, 6
6, 7
7, 8
8, 9