deque-pop_back

////////////////////////////////////////
//      2018/04/24 19:52:51
//      deque-pop_back

#include <iostream>
#include <deque>
#include <algorithm>

using namespace std;

template<class T>
class Print
{
public:
    void operator ()(T& t){
        cout << t << " ";
    }
};
//===========================
int main(){
    deque<int> d;
    Print<int> print;
    for (int i = 0; i < 5; i++){
        d.push_back(i + 1);
    }
    while (!d.empty()){
        for_each(d.begin(), d.end(), print);
        cout << endl;
        d.pop_back();
    }

    return 0;
}

/*
OUTPUT:
    1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1
*/ 
posted @ 2018-04-24 20:22  老耗子  阅读(57)  评论(0编辑  收藏  举报