////////////////////////////////////////
//      2018/04/25 21:28:52
//      list-erase

// erase an element
#include <iostream>
#include <list>
#include <algorithm>
#include <numeric>

using namespace std;

template<class T>
void print(list<T>& t){
    list<T>::iterator it = t.begin();
    while (it != t.end()){
        cout << *(it++) << " ";
    }
    cout << endl;
}

//===============================

int main(){
    list<int> li(10);
    iota(li.begin(), li.end(), 1);
    print<int>(li);

    list<int>::iterator it;

    it = find(li.begin(), li.end(), 6);
    // erase at the pos it
    li.erase(it);
    print<int>(li);

    it = find(li.begin(), li.end(), 4);
    // erase form beginning to the pos it
    li.erase(li.begin(), it);
    print<int>(li);

    return 0;
}


/*
OUTPUT:
    1 2 3 4 5 6 7 8 9 10
    1 2 3 4 5 7 8 9 10
    4 5 7 8 9 10
*/