testvector.cpp
578 Bytes
#include <iostream>
using namespace std;
#include "vector.h"
template <class C> void printvector(vector<C> v) { cout << v << endl; }
int main() {
vector<string> a(0);
vector<string> b(0);
a.push_back("1");
a.push_back("2");
a.push_back("3");
a.push_back("4");
a.push_back("5");
a.push_back("6");
a.push_back("7");
a.reserve(11); // to avoid reallocation and reference invalidation
auto [x, y, z] = a.push_back("8", "9", "10");
printvector(a);
x = "108";
y = "109";
z = "110";
string arg = "11";
a.push_back(arg);
b = a;
printvector(b);
}