#include #include #include #include #include #include #include #include "placementalloc.h" #include "plainalloc.h" #include "newalloc.h" #include "storage.h" using namespace std; int main(int argc, char **argv) { switch (argv[1][0]) { default: cout << "Provide argument to read from stdin:\n" "n: read strings, using NewAlloc with a vector\n" "p: read strings, using PlacementAlloc with a deque\n" "s: read ints, using a simple PlainAlloc with a list\n"; break; case 'n': { Storage storage; copy(istream_iterator(cin), istream_iterator(), back_inserter(storage)); cout << "Element index 1 is " << storage[1] << '\n'; storage[1] = "hello"; copy(storage.begin(), storage.end(), ostream_iterator >(cout, "\n")); } break; case 'p': { Storage storage; copy(istream_iterator(cin), istream_iterator(), back_inserter(storage)); copy(storage.begin(), storage.end(), ostream_iterator >(cout, "\n")); } break; case 's': { Storage storage; copy(istream_iterator(cin), istream_iterator(), back_inserter(storage)); copy(storage.begin(), storage.end(), ostream_iterator >(cout, "\n")); } break; } }