// File: 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
subq $0x280, %rsp            # imm = 0x280
movl $0x0, -0x4(%rbp)
movl $0x8, %edi
callq 0x20d0
movq %rax, -0x10(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x2180
movq -0x230(%rbp), %rdx
leaq 0x1cf6(%rip), %rsi      # 0x4004
leaq -0x58(%rbp), %rdi
callq 0x2110
jmp 0x2319
movq 0x4cd0(%rip), %rdx      # 0x6ff0
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x27c0
jmp 0x232f
leaq -0x58(%rbp), %rdi
callq 0x2080
leaq -0x59(%rbp), %rdi
callq 0x2100
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x2800
jmp 0x2350
movl $0x4, %edi
callq 0x20d0
movq %rax, -0x238(%rbp)
jmp 0x2363
movq -0x238(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x2180
movq -0x240(%rbp), %rdx
leaq 0x1c75(%rip), %rsi      # 0x4004
leaq -0xc0(%rbp), %rdi
callq 0x2110
jmp 0x239d
movq 0x4c4c(%rip), %rdx      # 0x6ff0
leaq -0xa0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x27c0
jmp 0x23b9
movq -0x78(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2870
jmp 0x23cb
leaq -0xa0(%rbp), %rdi
callq 0x28e0
leaq -0xc0(%rbp), %rdi
callq 0x2080
leaq -0xc1(%rbp), %rdi
callq 0x2100
movl $0x4, %edi
callq 0x20d0
movq %rax, -0x248(%rbp)
jmp 0x2402
leaq -0x141(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x2180
movq -0x250(%rbp), %rdx
leaq 0x1bef(%rip), %rsi      # 0x4012
leaq -0x140(%rbp), %rdi
callq 0x2110
jmp 0x2431
movq 0x4bb8(%rip), %rdx      # 0x6ff0
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x27c0
jmp 0x244d
movq -0x248(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
leaq -0x120(%rbp), %rdx
movq %rdx, -0x260(%rbp)
callq 0x2900
movq -0x260(%rbp), %rdi
callq 0x28e0
leaq -0x140(%rbp), %rdi
callq 0x2080
leaq -0x141(%rbp), %rdi
callq 0x2100
movl $0x20, %edi
callq 0x20d0
movq %rax, -0x258(%rbp)
jmp 0x24a5
movq -0x258(%rbp), %rdi
callq 0x2120
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x268(%rbp)
callq 0x2180
movq -0x268(%rbp), %rdx
leaq 0x1b40(%rip), %rsi      # 0x4012
leaq -0x1c0(%rbp), %rdi
callq 0x2110
jmp 0x24e0
movq 0x4b09(%rip), %rdx      # 0x6ff0
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x27c0
jmp 0x24fc
movq -0x258(%rbp), %rsi
leaq -0x178(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
movq %rdx, -0x278(%rbp)
callq 0x2940
movq -0x278(%rbp), %rdi
callq 0x28e0
leaq -0x1c0(%rbp), %rdi
callq 0x2080
leaq -0x1c1(%rbp), %rdi
callq 0x2100
movl $0x4, %edi
callq 0x20d0
movq %rax, -0x270(%rbp)
jmp 0x2554
movq -0x270(%rbp), %rax
movl $0x2a, (%rax)
leaq -0x221(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x2180
movq -0x280(%rbp), %rdx
leaq 0x1a9b(%rip), %rsi      # 0x401d
leaq -0x220(%rbp), %rdi
callq 0x2110
jmp 0x2590
movq 0x4a59(%rip), %rdx      # 0x6ff0
leaq -0x200(%rbp), %rdi
leaq -0x220(%rbp), %rsi
callq 0x27c0
jmp 0x25ac
movq -0x270(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
leaq -0x200(%rbp), %rdx
callq 0x2980
jmp 0x25c8
leaq -0x200(%rbp), %rdi
callq 0x28e0
leaq -0x220(%rbp), %rdi
callq 0x2080
leaq -0x221(%rbp), %rdi
callq 0x2100
movl $0x0, -0x4(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x2a00
leaq -0x178(%rbp), %rdi
callq 0x2a20
leaq -0xf8(%rbp), %rdi
callq 0x2a90
leaq -0x38(%rbp), %rdi
callq 0x28e0
movl -0x4(%rbp), %eax
addq $0x280, %rsp            # imm = 0x280
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x264f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2080
leaq -0x59(%rbp), %rdi
callq 0x2100
jmp 0x27b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x27ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x28e0
leaq -0xc0(%rbp), %rdi
callq 0x2080
leaq -0xc1(%rbp), %rdi
callq 0x2100
jmp 0x27ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x26e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x2080
leaq -0x141(%rbp), %rdi
callq 0x2100
jmp 0x27ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x27a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x272d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x2080
leaq -0x1c1(%rbp), %rdi
callq 0x2100
jmp 0x27a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2795
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2789
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x277d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x28e0
leaq -0x220(%rbp), %rdi
callq 0x2080
leaq -0x221(%rbp), %rdi
callq 0x2100
leaq -0x178(%rbp), %rdi
callq 0x2a20
leaq -0xf8(%rbp), %rdi
callq 0x2a90
leaq -0x38(%rbp), %rdi
callq 0x28e0
movq -0x68(%rbp), %rdi
callq 0x2170
nop