// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH17_SpecializedLibraryFacilities/examples/tuple.cc
// Function: main
int main()
{
	// tuple that represents a bookstore transaction: 
	// ISBN, count, price per book
	auto item = make_tuple("0-999-78345-X", 3, 20.00);
	auto book = get<0>(item);      // returns the first member of item
	auto cnt = get<1>(item);       // returns the second member of item
	auto price = get<2>(item)/cnt; // returns the last member of item
	get<2>(item) *= 0.8;           // apply 20% discount
	
	cout << book << " " << cnt << " " << price << endl;

	typedef decltype(item) trans; // trans is the type of item 
	
	// returns the number of members in object's of type trans
	size_t sz = tuple_size<trans>::value;  // returns 3

	// cnt has the same type as the second member in item
	tuple_element<1, trans>::type cnt2 = get<1>(item); // cnt is an int
	tuple_element<0, trans>::type book2 = get<0>(item);
	tuple_element<2, trans>::type price2 = get<2>(item);
	cout << tuple_size<trans>::value << endl;
	
	cout << book2 << " " << cnt2 << " " << price2 << endl;
	
	tuple<size_t, size_t, size_t> threeD;  // all three members set to 0
	tuple<string, vector<double>, int, list<int>>
	    someVal("constants", {3.14, 2.718}, 42, {0,1,2,3,4,5});
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq 0x2d13(%rip), %r14      # 0x3fd8
leaq 0xd4c(%rip), %r15       # 0x2018
movq %r14, %rdi
movq %r15, %rsi
callq 0x10e0
leaq 0xd48(%rip), %rbx       # 0x2026
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10e0
pushq $0x3
popq %r12
movq %rax, %rdi
movl %r12d, %esi
callq 0x1150
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10e0
movsd 0xcfd(%rip), %xmm0      # 0x2008
movq %rax, %rdi
callq 0x1130
movq %rax, %rdi
callq 0x1090
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0x10b0
movq %rax, %rdi
callq 0x1090
movq %r14, %rdi
movq %r15, %rsi
callq 0x10e0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10e0
movq %rax, %rdi
movl %r12d, %esi
callq 0x1150
movq %rax, %rdi
movq %rbx, %rsi
callq 0x10e0
movsd 0xcae(%rip), %xmm0      # 0x2010
movq %rax, %rdi
callq 0x1130
movq %rax, %rdi
callq 0x1090
leaq 0xcaf(%rip), %rsi       # 0x2028
leaq -0x78(%rbp), %rdi
leaq -0x23(%rbp), %rdx
callq 0x1060
movabsq $0x40091eb851eb851f, %rax # imm = 0x40091EB851EB851F
leaq -0x88(%rbp), %rsi
movq %rax, (%rsi)
movabsq $0x4005be76c8b43958, %rax # imm = 0x4005BE76C8B43958
movq %rax, 0x8(%rsi)
leaq -0x58(%rbp), %rdi
pushq $0x2
popq %rdx
leaq -0x22(%rbp), %rcx
callq 0x1474
movl $0x2a, -0x28(%rbp)
movups 0xc9e(%rip), %xmm0      # 0x2064
leaq -0xa0(%rbp), %rsi
movaps %xmm0, (%rsi)
movabsq $0x500000004, %rax      # imm = 0x500000004
movq %rax, 0x10(%rsi)
leaq -0x40(%rbp), %rdi
pushq $0x6
popq %rdx
leaq -0x21(%rbp), %rcx
callq 0x14aa
leaq -0xf8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0x28(%rbp), %rcx
leaq -0x40(%rbp), %r8
callq 0x1510
leaq -0x40(%rbp), %rdi
callq 0x172a
leaq -0x58(%rbp), %rdi
callq 0x17b6
leaq -0x78(%rbp), %rdi
callq 0x1080
leaq -0xf8(%rbp), %rdi
callq 0x14e2
xorl %eax, %eax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x172a
jmp 0x1454
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x17b6
jmp 0x1462
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x1080
movq %rbx, %rdi
callq 0x1160
nop