Source of deque03.cpp


  1: //deque03.cpp

  3: #include <iostream>
  4: #include <iomanip>
  5: #include <string>
  6: #include <deque>
  7: using namespace std;


 10: int main()
 11: {
 12:     cout << "\nThis program illustrates the member function max_size() "
 13:         "and shows how the\nmaximum size of a deque depends on its "
 14:         "component type.";
 15:     cout << "\nPress Enter to continue ... ";  cin.ignore(80, '\n');

 17:     cout << "\nHere are the maximum sizes of several deques "
 18:         "of different component types:\n\n";

 20:     deque<int> d1;
 21:     deque<double> d2;
 22:     deque<bool> d3;
 23:     deque<char> d4;

 25:     //Just something that takes up a lot of space
 26:     struct BigThing
 27:     {
 28:         double first[10000];
 29:         double second[1000000];
 30:     };
 31:     deque<BigThing> d5;

 33:     cout << "Maximum size of a deque<int> ......."
 34:         << setw(11) << d1.max_size() << "\n"
 35:         << "Maximum size of a deque<double> ...."
 36:         << setw(11) << d2.max_size() << "\n"
 37:         << "Maximum size of a deque<bool> ......"
 38:         << setw(11) << d3.max_size() << "\n"
 39:         << "Maximum size of a deque<char> ......"
 40:         << setw(11) << d4.max_size() << "\n"
 41:         << "Maximum size of a deque<BigThing> .."
 42:         << setw(11) << d5.max_size() << "\n\n";
 43:     cout << "Press Enter to continue ... ";  cin.ignore(80, '\n');
 44: }