// File: iZhangHui[P]CppPrimer/CH13_CopyControl/examples/useStrVec.cc
// Function: main
int main()
{
	StrVec sv = {"one", "two", "three"};
	// run the string empty funciton on the first element in sv
	if (!sv[0].empty())
		sv[0] = "None"; // assign a new value to the first string

	// we'll call getVec a couple of times
	// and will read the same file each time
	ifstream in("data/storyDataFile");
	std::cout << "HenryDbg::tp1------------------->" << std::endl;
	StrVec svec = getVec(in);
	std::cout << "HenryDbg::tp1------------------->" << std::endl;
	print(svec);
	in.close();

	cout << "copy " << svec.size() << endl;
	std::cout << "HenryDbg::tp2------------------->" << std::endl;
	auto svec2 = svec;
	std::cout << "HenryDbg::tp2------------------->" << std::endl;
	print(svec2);

	cout << "assign" << endl;
	StrVec svec3;
	std::cout << "HenryDbg::tp3------------------->" << std::endl;
	svec3 = svec2;
	std::cout << "HenryDbg::tp3------------------->" << std::endl;
	print(svec3);

	StrVec v1, v2;
	std::cout << "HenryDbg::tp4------------------->" << std::endl;
	v1 = v2;                   // v2 is an lvalue; copy assignment
	std::cout << "HenryDbg::tp4------------------->" << std::endl;

	in.open("data/storyDataFile");
	std::cout << "HenryDbg::tp5------------------->" << std::endl;
	v2 = getVec(in);          // getVec(in) is an rvalue; move assignment
	std::cout << "HenryDbg::tp5------------------->" << std::endl;
	in.close();

	StrVec vec;  // empty StrVec
	string s = "some string or another";
	std::cout << "HenryDbg::tp6------------------->" << std::endl;
	vec.push_back(s);      // calls push_back(const string&)
	vec.push_back("done"); // calls push_back(string&&)
	std::cout << "HenryDbg::tp6------------------->" << std::endl;

	// emplace member covered in chpater 16
	s = "the end";
	std::cout << "HenryDbg::tp7------------------->" << std::endl;
	vec.emplace_back(10, 'c'); // adds cccccccccc as a new last element
	vec.emplace_back(s);  // uses the string copy constructor
	string s1 = "the beginning", s2 = s;
	vec.emplace_back(s1 + s2); // uses the move constructor
	std::cout << "HenryDbg::tp7------------------->" << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x550, %rsp            # imm = 0x550
movl $0x0, -0x4(%rbp)
movb $0x1, -0xaf(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x430(%rbp)
movq %rax, -0x98(%rbp)
leaq -0x99(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0x2200
movq -0x430(%rbp), %rdi
movq -0x428(%rbp), %rdx
leaq 0x19d9(%rip), %rsi      # 0x400f
callq 0x2190
jmp 0x263d
leaq -0x70(%rbp), %rax
movq %rax, -0x440(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xad(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x2200
movq -0x440(%rbp), %rdi
movq -0x438(%rbp), %rdx
leaq 0x198d(%rip), %rsi      # 0x4004
callq 0x2190
jmp 0x267e
leaq -0x50(%rbp), %rax
movq %rax, -0x450(%rbp)
movq %rax, -0x98(%rbp)
leaq -0xae(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x2200
movq -0x450(%rbp), %rdi
movq -0x448(%rbp), %rdx
leaq 0x1950(%rip), %rsi      # 0x4008
callq 0x2190
jmp 0x26bf
movb $0x0, -0xaf(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x3, -0x28(%rbp)
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x32c0
jmp 0x26ec
leaq -0x90(%rbp), %rax
movq %rax, -0x460(%rbp)
addq $0x60, %rax
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x468(%rbp)
callq 0x20b0
movq -0x460(%rbp), %rcx
movq -0x468(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x458(%rbp)
jne 0x2705
leaq -0xae(%rbp), %rdi
callq 0x2150
leaq -0xad(%rbp), %rdi
callq 0x2150
leaq -0x99(%rbp), %rdi
callq 0x2150
xorl %eax, %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0x3330
movq %rax, -0x470(%rbp)
jmp 0x2770
movq -0x470(%rbp), %rdi
callq 0x21e0
testb $0x1, %al
jne 0x28e9
xorl %eax, %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0x3330
movq %rax, -0x478(%rbp)
jmp 0x279a
movq -0x478(%rbp), %rdi
leaq 0x1866(%rip), %rsi      # 0x400e
callq 0x2180
jmp 0x27af
jmp 0x28e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2869
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x285d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x2851
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0x488(%rbp)
addq $0x60, %rax
movq %rax, -0x480(%rbp)
movq -0x480(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x490(%rbp)
callq 0x20b0
movq -0x488(%rbp), %rcx
movq -0x490(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x480(%rbp)
jne 0x281e
jmp 0x2851
leaq -0xae(%rbp), %rdi
callq 0x2150
leaq -0xad(%rbp), %rdi
callq 0x2150
leaq -0x99(%rbp), %rdi
callq 0x2150
testb $0x1, -0xaf(%rbp)
jne 0x2880
jmp 0x28cd
movq -0x98(%rbp), %rax
leaq -0x90(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x498(%rbp)
je 0x28cb
movq -0x498(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x20b0
movq -0x4a0(%rbp), %rax
leaq -0x90(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x498(%rbp)
jne 0x289a
jmp 0x28cd
jmp 0x317a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3171
leaq 0x1723(%rip), %rsi      # 0x4013
leaq -0x2b8(%rbp), %rdi
movl $0x8, %edx
callq 0x2210
jmp 0x2903
movq 0x36ce(%rip), %rdi      # 0x5fd8
leaq 0x1715(%rip), %rsi      # 0x4026
callq 0x2110
movq %rax, -0x4a8(%rbp)
jmp 0x291f
movq -0x4a8(%rbp), %rdi
movq 0x369b(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2934
leaq -0x2d0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x2510
jmp 0x2949
movq 0x3688(%rip), %rdi      # 0x5fd8
leaq 0x16cf(%rip), %rsi      # 0x4026
callq 0x2110
movq %rax, -0x4b0(%rbp)
jmp 0x2965
movq -0x4b0(%rbp), %rdi
movq 0x3655(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x297a
leaq -0x2d0(%rbp), %rdi
callq 0x2440
jmp 0x2988
leaq -0x2b8(%rbp), %rdi
callq 0x2030
jmp 0x2996
movq 0x363b(%rip), %rdi      # 0x5fd8
leaq 0x16a4(%rip), %rsi      # 0x4048
callq 0x2110
movq %rax, -0x4b8(%rbp)
jmp 0x29b2
leaq -0x2d0(%rbp), %rdi
callq 0x3350
movq %rax, -0x4c0(%rbp)
jmp 0x29c7
movq -0x4c0(%rbp), %rsi
movq -0x4b8(%rbp), %rdi
callq 0x2040
movq %rax, -0x4c8(%rbp)
jmp 0x29e3
movq -0x4c8(%rbp), %rdi
movq 0x35d7(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x29f8
movq 0x35d9(%rip), %rdi      # 0x5fd8
leaq 0x1648(%rip), %rsi      # 0x404e
callq 0x2110
movq %rax, -0x4d0(%rbp)
jmp 0x2a14
movq -0x4d0(%rbp), %rdi
movq 0x35a6(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2a29
leaq -0x2e8(%rbp), %rdi
leaq -0x2d0(%rbp), %rsi
callq 0x3370
jmp 0x2a3e
movq 0x3593(%rip), %rdi      # 0x5fd8
leaq 0x1602(%rip), %rsi      # 0x404e
callq 0x2110
movq %rax, -0x4d8(%rbp)
jmp 0x2a5a
movq -0x4d8(%rbp), %rdi
movq 0x3560(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2a6f
leaq -0x2e8(%rbp), %rdi
callq 0x2440
jmp 0x2a7d
movq 0x3554(%rip), %rdi      # 0x5fd8
leaq 0x15e5(%rip), %rsi      # 0x4070
callq 0x2110
movq %rax, -0x4e0(%rbp)
jmp 0x2a99
movq -0x4e0(%rbp), %rdi
movq 0x3521(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2aae
leaq -0x300(%rbp), %rdi
callq 0x31d0
jmp 0x2abc
movq 0x3515(%rip), %rdi      # 0x5fd8
leaq 0x15ad(%rip), %rsi      # 0x4077
callq 0x2110
movq %rax, -0x4e8(%rbp)
jmp 0x2ad8
movq -0x4e8(%rbp), %rdi
movq 0x34e2(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2aed
leaq -0x300(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x3400
jmp 0x2b02
movq 0x34cf(%rip), %rdi      # 0x5fd8
leaq 0x1567(%rip), %rsi      # 0x4077
callq 0x2110
movq %rax, -0x4f0(%rbp)
jmp 0x2b1e
movq -0x4f0(%rbp), %rdi
movq 0x349c(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2b33
leaq -0x300(%rbp), %rdi
callq 0x2440
jmp 0x2b41
leaq -0x318(%rbp), %rdi
callq 0x31d0
jmp 0x2b4f
leaq -0x330(%rbp), %rdi
callq 0x31d0
jmp 0x2b5d
movq 0x3474(%rip), %rdi      # 0x5fd8
leaq 0x152e(%rip), %rsi      # 0x4099
callq 0x2110
movq %rax, -0x4f8(%rbp)
jmp 0x2b79
movq -0x4f8(%rbp), %rdi
movq 0x3441(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2b8e
leaq -0x318(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x3400
jmp 0x2ba3
movq 0x342e(%rip), %rdi      # 0x5fd8
leaq 0x14e8(%rip), %rsi      # 0x4099
callq 0x2110
movq %rax, -0x500(%rbp)
jmp 0x2bbf
movq -0x500(%rbp), %rdi
movq 0x33fb(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2bd4
leaq 0x1438(%rip), %rsi      # 0x4013
leaq -0x2b8(%rbp), %rdi
movl $0x8, %edx
callq 0x20c0
jmp 0x2bee
movq 0x33e3(%rip), %rdi      # 0x5fd8
leaq 0x14bf(%rip), %rsi      # 0x40bb
callq 0x2110
movq %rax, -0x508(%rbp)
jmp 0x2c0a
movq -0x508(%rbp), %rdi
movq 0x33b0(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2c1f
leaq -0x348(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x2510
jmp 0x2c34
leaq -0x330(%rbp), %rdi
leaq -0x348(%rbp), %rsi
movq %rsi, -0x518(%rbp)
callq 0x3490
movq -0x518(%rbp), %rdi
callq 0x3290
movq 0x3377(%rip), %rdi      # 0x5fd8
leaq 0x1453(%rip), %rsi      # 0x40bb
callq 0x2110
movq %rax, -0x510(%rbp)
jmp 0x2c76
movq -0x510(%rbp), %rdi
movq 0x3344(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2c8b
leaq -0x2b8(%rbp), %rdi
callq 0x2030
jmp 0x2c99
leaq -0x360(%rbp), %rdi
callq 0x31d0
jmp 0x2ca7
leaq -0x381(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x2200
movq -0x520(%rbp), %rdx
leaq 0x1415(%rip), %rsi      # 0x40dd
leaq -0x380(%rbp), %rdi
callq 0x2190
jmp 0x2cd6
leaq -0x381(%rbp), %rdi
callq 0x2150
movq 0x32ef(%rip), %rdi      # 0x5fd8
leaq 0x1404(%rip), %rsi      # 0x40f4
callq 0x2110
movq %rax, -0x528(%rbp)
jmp 0x2cfe
movq -0x528(%rbp), %rdi
movq 0x32bc(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2d13
leaq -0x360(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3220
jmp 0x2d28
leaq -0x3a9(%rbp), %rdi
movq %rdi, -0x530(%rbp)
callq 0x2200
movq -0x530(%rbp), %rdx
leaq 0x13cd(%rip), %rsi      # 0x4116
leaq -0x3a8(%rbp), %rdi
callq 0x2190
jmp 0x2d57
leaq -0x360(%rbp), %rdi
leaq -0x3a8(%rbp), %rsi
callq 0x3550
jmp 0x2d6c
leaq -0x3a8(%rbp), %rdi
callq 0x20b0
leaq -0x3a9(%rbp), %rdi
callq 0x2150
movq 0x324d(%rip), %rdi      # 0x5fd8
leaq 0x1362(%rip), %rsi      # 0x40f4
callq 0x2110
movq %rax, -0x538(%rbp)
jmp 0x2da0
movq -0x538(%rbp), %rdi
movq 0x321a(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2db5
leaq 0x135f(%rip), %rsi      # 0x411b
leaq -0x380(%rbp), %rdi
callq 0x2180
jmp 0x2dca
movq 0x3207(%rip), %rdi      # 0x5fd8
leaq 0x134b(%rip), %rsi      # 0x4123
callq 0x2110
movq %rax, -0x540(%rbp)
jmp 0x2de6
movq -0x540(%rbp), %rdi
movq 0x31d4(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2dfb
movl $0xa, -0x3b0(%rbp)
movb $0x63, -0x3b1(%rbp)
leaq -0x360(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
leaq -0x3b1(%rbp), %rdx
callq 0x35c0
jmp 0x2e28
leaq -0x360(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3610
jmp 0x2e3d
leaq -0x3d9(%rbp), %rdi
movq %rdi, -0x548(%rbp)
callq 0x2200
movq -0x548(%rbp), %rdx
leaq 0x12e7(%rip), %rsi      # 0x4145
leaq -0x3d8(%rbp), %rdi
callq 0x2190
jmp 0x2e6c
leaq -0x3d9(%rbp), %rdi
callq 0x2150
leaq -0x400(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x2090
jmp 0x2e8d
leaq -0x420(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
leaq -0x400(%rbp), %rdx
callq 0x36b0
jmp 0x2ea9
leaq -0x360(%rbp), %rdi
leaq -0x420(%rbp), %rsi
callq 0x3660
jmp 0x2ebe
leaq -0x420(%rbp), %rdi
callq 0x20b0
movq 0x3107(%rip), %rdi      # 0x5fd8
leaq 0x124b(%rip), %rsi      # 0x4123
callq 0x2110
movq %rax, -0x550(%rbp)
jmp 0x2ee6
movq -0x550(%rbp), %rdi
movq 0x30d4(%rip), %rsi      # 0x5fc8
callq 0x2140
jmp 0x2efb
movl $0x0, -0x4(%rbp)
leaq -0x400(%rbp), %rdi
callq 0x20b0
leaq -0x3d8(%rbp), %rdi
callq 0x20b0
leaq -0x380(%rbp), %rdi
callq 0x20b0
leaq -0x360(%rbp), %rdi
callq 0x3290
leaq -0x330(%rbp), %rdi
callq 0x3290
leaq -0x318(%rbp), %rdi
callq 0x3290
leaq -0x300(%rbp), %rdi
callq 0x3290
leaq -0x2e8(%rbp), %rdi
callq 0x3290
leaq -0x2d0(%rbp), %rdi
callq 0x3290
leaq -0x2b8(%rbp), %rdi
callq 0x2050
leaq -0x20(%rbp), %rdi
callq 0x3290
movl -0x4(%rbp), %eax
addq $0x550, %rsp            # imm = 0x550
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3165
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3159
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x314d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3141
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3135
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3129
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x381(%rbp), %rdi
callq 0x2150
jmp 0x311d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3111
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3085
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0x20b0
leaq -0x3a9(%rbp), %rdi
callq 0x2150
jmp 0x3111
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x3d9(%rbp), %rdi
callq 0x2150
jmp 0x3111
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x3105
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
jmp 0x30f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa8(%rbp)
movl %eax, -0xac(%rbp)
leaq -0x420(%rbp), %rdi
callq 0x20b0
leaq -0x400(%rbp), %rdi
callq 0x20b0
leaq -0x3d8(%rbp), %rdi
callq 0x20b0
leaq -0x380(%rbp), %rdi
callq 0x20b0
leaq -0x360(%rbp), %rdi
callq 0x3290
leaq -0x330(%rbp), %rdi
callq 0x3290
leaq -0x318(%rbp), %rdi
callq 0x3290
leaq -0x300(%rbp), %rdi
callq 0x3290
leaq -0x2e8(%rbp), %rdi
callq 0x3290
leaq -0x2d0(%rbp), %rdi
callq 0x3290
leaq -0x2b8(%rbp), %rdi
callq 0x2050
leaq -0x20(%rbp), %rdi
callq 0x3290
movq -0xa8(%rbp), %rdi
callq 0x21f0
nopw %cs:(%rax,%rax)