deque-pop_front

////////////////////////////////////////
//      2018/04/24 19:57:03
//      deque-pop_front

#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_front();
    }
    return 0;
}

/*
OUTPUT:
    1 2 3 4 5
    2 3 4 5
    3 4 5
    4 5
    5
*/ 
原文地址:https://www.cnblogs.com/laohaozi/p/12537991.html