-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.cpp
64 lines (51 loc) · 1.56 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<iostream>
#include<string>
#include<utility>
#include "StrVec.h"
int main()
{
StrVec v;
v.push_back("123");
v.push_back("456");
v.push_back("789");
v = v;
v = {"123", "456", "789"};
StrVec v1 = v;
for(std::string * p = v1.begin(); p != v1.end(); ++p)
std::cout << *p << " ";
std::cout << std::endl;
v1.reserve(10);
std::cout << v1.size() << " " << v1.capacity() << std::endl;
v1.resize(20, "q");
std::cout << v1.size() << " " << v1.capacity() << std::endl;
for(std::string * p = v1.begin(); p != v1.end(); ++p)
std::cout << *p << " | ";
v1.resize(5);
std::cout << v1.size() << " " << v1.capacity() << std::endl;
for(std::string * p = v1.begin(); p != v1.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
StrVec v2 = {"1","2","3"};
for(std::string * p = v2.begin(); p != v2.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
StrVec v5(std::move(v2));
for(std::string * p = v5.begin(); p != v5.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
v = std::move(v5);
for(std::string * p = v.begin(); p != v.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
for(std::string * p = v5.begin(); p != v5.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
std::cout << (v == v5) << " " << (v > v5) << " " << (v < v5) << " " << (v <= v5) << " " << (v >= v5) << " " << std::endl;
v[1] = "12";
std::cout << v[0] << " "<< v[1] << std::endl;
v.emplace_back(10,'c');
for(std::string * p = v.begin(); p != v.end(); ++p)
std::cout << *p << " | ";
std::cout << std::endl;
return 0;
}