// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/exercises/ex16_30_31.cc
// Function: main
int main(int argc, char const *argv[])
{
	Blob<int> blob{1, 2, 3};
	blob.push_back(4);

	for (size_t i = 0; i != blob.size(); ++i) {
		std::cout << blob[i] << " ";
	}
	std::cout << std::endl;

	// int ret = blob.back();
	int& ret = blob.back();
	ret = 5;

	for (size_t i = 0; i != blob.size(); ++i) {
		std::cout << blob[i] << " ";
	}
	std::cout << std::endl;

	Blob<std::string> b1; // empty Blob
	std::cout << b1.size() << std::endl;
	{  // new scope
		Blob<std::string> b2 = {"a", "an", "the"};
		b1 = b2;  // b1 and b2 share the same elements
		b2.push_back("about");
		std::cout << b1.size() << " " << b2.size() << std::endl;
	} // b2 is destroyed, but the elements it points to must not be destroyed
	std::cout << b1.size() << std::endl;

	for (size_t i = 0; i != b1.size(); ++i) {
		std::cout << b1[i] << " ";
	}
	std::cout << std::endl;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movabsq $0x200000001, %rax      # imm = 0x200000001
leaq -0xe8(%rbp), %rbx
movq %rax, (%rbx)
movl $0x3, 0x8(%rbx)
leaq -0x88(%rbp), %r14
movl $0x3, %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2916
movl $0x4, (%rbx)
movq (%r14), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x23e5
movl $0x4, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x23fc
leaq -0xe8(%rbp), %rdx
callq 0x3118
movq -0x88(%rbp), %rdi
movq 0x8(%rdi), %rsi
cmpq (%rdi), %rsi
je 0x2450
xorl %ebx, %ebx
movq 0x3bbe(%rip), %r15      # 0x5fc8
leaq 0x1bf3(%rip), %r12      # 0x4004
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2a00
movl (%rax), %esi
movq %r15, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2140
incq %rbx
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %rbx
jne 0x2411
movq 0x3b71(%rip), %rdi      # 0x5fc8
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x3b56(%rip), %rbx      # 0x5fc8
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x88(%rbp), %rdi
callq 0x2a96
movl $0x5, (%rax)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x24fb
xorl %r14d, %r14d
leaq -0x88(%rbp), %r15
movq 0x3b13(%rip), %r12      # 0x5fc8
leaq 0x1b48(%rip), %r13      # 0x4004
movq %r15, %rdi
movq %r14, %rsi
callq 0x2a00
movl (%rax), %esi
movq %r12, %rdi
callq 0x21b0
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
incq %r14
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x2, %rcx
cmpq %rcx, %r14
jne 0x24bc
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x3aaf(%rip), %rdi      # 0x5fc8
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x58(%rbp), %rdi
callq 0x2b20
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x3a83(%rip), %rdi      # 0x5fc8
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0xd8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1a7f(%rip), %rsi      # 0x4006
leaq 0x1a79(%rip), %rdx      # 0x4007
leaq -0xe8(%rbp), %r14
movq %r14, %rdi
callq 0x329e
leaq -0xc8(%rbp), %r15
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x1a52(%rip), %rsi      # 0x4008
leaq 0x1a4d(%rip), %rdx      # 0x400a
movq %r15, %rdi
callq 0x329e
leaq -0xa8(%rbp), %r15
leaq -0x98(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1a2d(%rip), %rsi      # 0x400b
leaq 0x1a29(%rip), %rdx      # 0x400e
movq %r15, %rdi
callq 0x329e
leaq -0x118(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
movl $0x3, %edx
callq 0x2bda
movq $-0x60, %r14
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x2620
movq (%rbx), %rsi
incq %rsi
callq 0x2130
addq $-0x20, %rbx
addq $0x20, %r14
jne 0x260c
movq -0x110(%rbp), %rax
incq (%rax)
cmpq $0x0, -0x58(%rbp)
je 0x2679
movq -0x50(%rbp), %rdi
decq (%rdi)
jne 0x2679
movl $0x8, %esi
callq 0x2130
movq -0x58(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x2861
leaq -0x48(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq *0x18(%rdi)
movq -0x110(%rbp), %rax
leaq -0x108(%rbp), %rsi
movq -0x10(%rsi), %rcx
leaq -0x48(%rbp), %rdi
movq %rcx, -0x10(%rdi)
movq %rax, -0x8(%rdi)
callq 0x2d5a
leaq -0xe8(%rbp), %rdi
movq %r12, (%rdi)
leaq 0x1969(%rip), %rsi      # 0x400f
leaq 0x1967(%rip), %rdx      # 0x4014
callq 0x329e
movq -0x118(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3682
movq -0xe8(%rbp), %rdi
cmpq %r12, %rdi
je 0x26e0
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x2130
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x38d2(%rip), %rdi      # 0x5fc8
callq 0x20a0
movq %rax, %rbx
leaq 0x18ff(%rip), %rsi      # 0x4004
movl $0x1, %edx
movq %rax, %rdi
callq 0x2140
movq -0x118(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq %rbx, %rdi
callq 0x20a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x118(%rbp), %rdi
callq 0x2e42
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
subq (%rax), %rsi
sarq $0x5, %rsi
movq 0x3850(%rip), %rbx      # 0x5fc8
movq %rbx, %rdi
callq 0x20a0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20b0
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rcx
cmpq (%rax), %rcx
je 0x280d
xorl %r14d, %r14d
leaq -0x58(%rbp), %r15
movq 0x3803(%rip), %r12      # 0x5fc8
leaq 0x1838(%rip), %r13      # 0x4004
movq %r15, %rdi
movq %r14, %rsi
callq 0x2cc4
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %r12, %rdi
callq 0x2140
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
incq %r14
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x5, %rcx
cmpq %rcx, %r14
jne 0x27cc
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2110
movsbl %al, %esi
movq 0x379d(%rip), %rdi      # 0x5fc8
callq 0x2030
movq %rax, %rdi
callq 0x20b0
leaq -0x58(%rbp), %rdi
callq 0x2e42
leaq -0x88(%rbp), %rdi
callq 0x2eb4
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2060
jmp 0x28ff
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r12, %rdi
je 0x28df
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x2130
jmp 0x28df
jmp 0x28dc
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x21f0
jmp 0x28f2
jmp 0x28a7
movq %rax, %rbx
addq $-0x10, %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x28c2
movq (%r15), %rsi
incq %rsi
callq 0x2130
leaq -0x20(%r15), %rax
addq $-0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x28ae
jmp 0x28f2
jmp 0x28ef
jmp 0x28ff
jmp 0x28ff
jmp 0x28ff
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x2e42
jmp 0x28f2
jmp 0x28ef
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x2e42
jmp 0x2902
jmp 0x28ff
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x2eb4
movq %rbx, %rdi
callq 0x21c0