// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH16_TemplatesAndGenericProgramming/examples/SP.cc
// Function: main
int main()
{
	double* p = new double;
	// an object that can act like a delete expression
	DebugDelete d("plain pointer");
	d(p); // calls DebugDelete::operator()(double*), which deletes p

	int* ip = new int;
	// calls operator()(int*) on a temporary DebugDelete object
	DebugDelete("plain pointer")(ip);

	// destroying the the object to which upi points
	// instantiates DebugDelete::operator()<int>(int *)
	unique_ptr<int, DebugDelete> upi(new int, DebugDelete());

	// destroying the the object to which ups points
	// instantiates DebugDelete::operator()<string>(string*)
	unique_ptr<string, DebugDelete> ups(new string, DebugDelete());

	// illustrate other types using DebugDelete as their deleter
	shared_ptr<int> sp1(new int(42), DebugDelete("shared_ptr"));

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
pushq $0x8
popq %rdi
callq 0x20d0
movq %rax, %r14
leaq 0xd44(%rip), %rsi       # 0x3004
leaq -0xd0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
callq 0x2050
movq 0x2d16(%rip), %r12      # 0x4ff0
leaq -0x118(%rbp), %rbx
movq %r12, -0x8(%rbx)
leaq -0xd0(%rbp), %rsi
movq %rbx, %rdi
callq 0x2100
leaq -0xd0(%rbp), %rdi
callq 0x2070
leaq -0x120(%rbp), %rdi
movq %r14, %rsi
callq 0x2570
pushq $0x4
popq %rdi
callq 0x20d0
movq %rax, %r14
leaq 0xce3(%rip), %rsi       # 0x3004
leaq -0xa0(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x2050
leaq -0xc8(%rbp), %r15
movq %r12, -0x8(%r15)
leaq -0xa0(%rbp), %rsi
movq %r15, %rdi
callq 0x2100
leaq -0xd0(%rbp), %rdi
movq %r14, %rsi
callq 0x25b2
movq %r15, %rdi
callq 0x2070
leaq -0xa0(%rbp), %rdi
callq 0x2070
pushq $0x4
popq %rdi
callq 0x20d0
movq %rax, %r14
leaq 0xc92(%rip), %rsi       # 0x3012
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x2050
leaq -0x98(%rbp), %r15
movq %r12, -0x8(%r15)
leaq -0x50(%rbp), %rsi
movq %r15, %rdi
callq 0x2100
leaq -0xd0(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
movq %r14, %rsi
callq 0x275e
movq %r15, %rdi
callq 0x2070
leaq -0x50(%rbp), %rdi
callq 0x2070
pushq $0x20
popq %rdi
callq 0x20d0
movq %rax, %r14
addq $0x10, %rax
movq %rax, (%r14)
andq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
leaq 0xc24(%rip), %rsi       # 0x3012
leaq -0x70(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x2050
leaq -0x48(%rbp), %r15
movq %r12, -0x8(%r15)
leaq -0x70(%rbp), %rsi
movq %r15, %rdi
callq 0x2100
leaq -0xa0(%rbp), %rdi
leaq -0x50(%rbp), %rdx
movq %r14, %rsi
callq 0x27ca
movq %r15, %rdi
callq 0x2070
leaq -0x70(%rbp), %rdi
callq 0x2070
pushq $0x4
popq %rdi
callq 0x20d0
movq %rax, %r14
movl $0x2a, (%rax)
leaq 0xbd2(%rip), %rsi       # 0x301d
leaq -0x50(%rbp), %rdi
leaq -0x21(%rbp), %rdx
callq 0x2050
leaq -0xf0(%rbp), %r15
movq %r12, -0x8(%r15)
leaq -0x50(%rbp), %rsi
movq %r15, %rdi
callq 0x2100
leaq -0x70(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
movq %r14, %rsi
callq 0x25f4
movq %r15, %rdi
callq 0x2070
leaq -0x50(%rbp), %rdi
callq 0x2070
leaq -0x68(%rbp), %rdi
callq 0x26ce
leaq -0xa0(%rbp), %rdi
callq 0x264c
leaq -0xd0(%rbp), %rdi
callq 0x2686
movq %rbx, %rdi
callq 0x2070
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %r15, %rdi
callq 0x2070
jmp 0x24de
movq %rax, %r14
leaq -0x50(%rbp), %rdi
callq 0x2070
jmp 0x24ee
jmp 0x24eb
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
callq 0x264c
jmp 0x250f
movq %rax, %r14
leaq -0x70(%rbp), %rdi
callq 0x2070
jmp 0x250f
jmp 0x250c
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
callq 0x2686
jmp 0x254f
movq %rax, %r14
leaq -0x50(%rbp), %rdi
jmp 0x2541
jmp 0x254c
jmp 0x254c
movq %rax, %r14
movq %r15, %rdi
callq 0x2070
jmp 0x253a
movq %rax, %r14
leaq -0xa0(%rbp), %rdi
callq 0x2070
jmp 0x254f
jmp 0x254c
jmp 0x254c
movq %rax, %r14
movq %rbx, %rdi
callq 0x2070
movq %r14, %rdi
callq 0x2150
movq %rax, %r14
leaq -0xd0(%rbp), %rdi
jmp 0x2552
movq %rax, %r14
jmp 0x2557