deque::begin(), deque::end()



#include <deque>
#include <iostream>
#include <algorithm>
                
using std::deque,
    std::cerr,
    std::begin,
    std::end,
    std::for_each;
            
typedef deque<int> my_int_deque;
            
int main(){
    my_int_deque a { 2, 4, 6, 8, 10};
            
    auto print = [](const int& n) { cerr << n << ' '; };
    for_each(begin(a), end(a), print);
    cerr << "\n";
            
    //begin()
    my_int_deque::iterator pos = a.begin();
    cerr << "begin: " << *pos << "\n";

    //end()
    while(pos != a.end()){
        cerr << *pos;
        if(pos != a.end() - 1){
            cerr << ", ";
        }
        ++pos;
    }
    cerr << "\n";
            
    return 0;
}
C++ Examples© 2024 TBD