vector-pop_back

////////////////////////////////////////
//      2018/04/17 20:46:59
//      vector-pop_back
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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