cpp/named req/ReversibleContainer
From cppreference.com
Template:cpp/concept/title Template:cpp/concept/navbar
The concept Template:concept is a Forward Container whose iterators are Bidirectional Iterators. It allows backwards iteration through the container. It means that it can produce iterators that move backward from the end, as well as iterators that move forward from the beginning.
Standard library
The following standard library facilities.
Example
The following example uses vector but will work with all containers that support iteration.
Run this code
#include <fstream> #include <iostream> #include <string> #include <vector> #include "../require.h" using namespace std; int main() { ifstream in("Reversible.cpp"); assure(in, "Reversible.cpp"); string line; vector<string> lines; while(getline(in, line)) lines.push_back(line); for(vector<string>::reverse_iterator r = lines.rbegin(); r != lines.rend(); r++) cout << *r << endl; }