// File: iZhangHui[P]CppPrimer/CH19_SpecializedToolsAndTechniques/examples/memFN-bind.cc
// Function: main
int main()
{
    vector<string> svec = {"hi", "bye"};
    // bind each string in the range to the implicit first argument to empty
    auto it = find_if(svec.begin(), svec.end(), 
	                  bind(&string::empty, _1));
    if (it == svec.end()) 
		cout << "worked" << endl; 
	else 
		cout << "failed"  << endl;
	auto f =  bind(&string::empty, _1);
	f(*svec.begin()); // ok: argument is a string f will use .* to call empty
	f(&svec[0]); // ok: argument is a pointer to string f will use .-> to call empty
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl $0x0, -0x4(%rbp)
movb $0x1, -0x8e(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x120(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x1150
movq -0x120(%rbp), %rdi
movq -0x118(%rbp), %rdx
leaq 0x1d27(%rip), %rsi      # 0x3014
callq 0x1100
jmp 0x12f4
leaq -0x50(%rbp), %rax
movq %rax, -0x130(%rbp)
movq %rax, -0x78(%rbp)
leaq -0x8d(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x1150
movq -0x130(%rbp), %rdi
movq -0x128(%rbp), %rdx
leaq 0x1cec(%rip), %rsi      # 0x3017
callq 0x1100
jmp 0x1332
movb $0x0, -0x8e(%rbp)
leaq -0x70(%rbp), %rax
movq %rax, -0x30(%rbp)
movq $0x2, -0x28(%rbp)
leaq -0x8f(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x16d0
movq -0x138(%rbp), %rcx
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
leaq -0x20(%rbp), %rdi
callq 0x16f0
jmp 0x1376
leaq -0x8f(%rbp), %rdi
callq 0x1770
leaq -0x70(%rbp), %rax
movq %rax, -0x148(%rbp)
addq $0x40, %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x150(%rbp)
callq 0x1080
movq -0x148(%rbp), %rcx
movq -0x150(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x140(%rbp)
jne 0x1398
leaq -0x8d(%rbp), %rdi
callq 0x10f0
leaq -0x79(%rbp), %rdi
callq 0x10f0
leaq -0x20(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x1800
movq -0x158(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0x1830
movq %rax, -0xa8(%rbp)
movq 0x4bc9(%rip), %rax      # 0x5fd8
movq %rax, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movq 0x4ba0(%rip), %rdx      # 0x5fc8
leaq -0xc0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x1860
jmp 0x143d
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
callq 0x1790
movq %rax, -0x160(%rbp)
jmp 0x1460
movq -0x160(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1830
movq %rax, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x18a0
testb $0x1, %al
jne 0x149a
jmp 0x15eb
movq 0x4b2f(%rip), %rdi      # 0x5fd0
leaq 0x1b73(%rip), %rsi      # 0x301b
callq 0x10b0
movq %rax, -0x168(%rbp)
jmp 0x14b6
movq -0x168(%rbp), %rdi
movq 0x4af4(%rip), %rsi      # 0x5fb8
callq 0x10e0
jmp 0x14cb
jmp 0x161e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x156e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x1562
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x8f(%rbp), %rdi
callq 0x1770
leaq -0x70(%rbp), %rax
movq %rax, -0x178(%rbp)
addq $0x40, %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x180(%rbp)
callq 0x1080
movq -0x178(%rbp), %rcx
movq -0x180(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x170(%rbp)
jne 0x152f
jmp 0x1562
leaq -0x8d(%rbp), %rdi
callq 0x10f0
leaq -0x79(%rbp), %rdi
callq 0x10f0
testb $0x1, -0x8e(%rbp)
jne 0x1582
jmp 0x15c6
movq -0x78(%rbp), %rax
leaq -0x70(%rbp), %rcx
cmpq %rax, %rcx
movq %rax, -0x188(%rbp)
je 0x15c4
movq -0x188(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x190(%rbp)
callq 0x1080
movq -0x190(%rbp), %rax
leaq -0x70(%rbp), %rcx
cmpq %rcx, %rax
movq %rax, -0x188(%rbp)
jne 0x1596
jmp 0x15c6
jmp 0x16be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x19a0
jmp 0x16be
movq 0x49de(%rip), %rdi      # 0x5fd0
leaq 0x1a29(%rip), %rsi      # 0x3022
callq 0x10b0
movq %rax, -0x198(%rbp)
jmp 0x1607
movq -0x198(%rbp), %rdi
movq 0x49a3(%rip), %rsi      # 0x5fb8
callq 0x10e0
jmp 0x161c
jmp 0x161e
movq 0x49b3(%rip), %rax      # 0x5fd8
movq %rax, -0x100(%rbp)
movq $0x0, -0xf8(%rbp)
movq 0x498a(%rip), %rdx      # 0x5fc8
leaq -0xf0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x1860
jmp 0x1653
leaq -0x20(%rbp), %rdi
callq 0x1800
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x1920
movq %rax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x18e0
jmp 0x1680
xorl %eax, %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0x1980
movq %rax, -0x110(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x1940
jmp 0x16a9
leaq -0x20(%rbp), %rdi
callq 0x19a0
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x1140
nopw (%rax,%rax)