TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 74

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 74', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | int main boost tuple int double tupl boost tuple long long long tup2 std cout Enter an int and a double as 1 n std cin tupl std cout Enter three ints as n std cin boost tuples set_open boost tuples set_close boost tuples set_delimiter . tup2 std cout Here they are n tupl n boost tuples set_open boost tuples set_close boost tuples set_delimiter - std cout tup2 n The previous example shows how to use the streaming operators together with tuples. The default delimiters for tuples are left parenthesis as opening delimiter right parenthesis for the closing delimiter and a space for delimiting tuple element values. This implies that to get our program working correctly we need to give the program input like 12 5 and . Here s a sample run. Enter an int and a double as 1 12 Enter three ints as Here they are 12 4-5-3 The support for streaming is convenient and with the support of the delimiter manipulators it s easy to make streaming compatible even with legacy code that has been updated to use tuples. Finding Out More About Tuples There are more facilities for tuples than those we ve already seen. These more advanced features are vital for creating generic constructs that work with tuples. For example you can get the length of a tuple the number of elements retrieve the type of an element and use the null_type tuple sentinel to terminate recursive template instantiations. It s not possible to iterate over the elements of a tuple with a for loop because get requires a constant integral expression. However using a template metaprogram we can print all the elements of a tuple. include iostream include string include boost tuple template typename Tuple int Index struct print_helper static void print const Tuple t std cout boost tuples get Index t n print_helper Tuple Index-1 print t template typename Tuple struct print_helper Tuple 0 static void print const Tuple t std cout boost tuples get 0 t n template typename Tuple .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.