Tuple and variable parameter templates in c++11

Source: Internet
Author: User

The tuple in c++11 is an n-ary variable tuple, which is equivalent to a struct with n elements, except that the members of the struct are anonymous, and a Get () method is provided in the tuple to get the value of the element corresponding to the subscript. You can also construct a tuple object by using the Make_tuple () method. The specific usage is as follows

We know that the number of elements in a tuple is indeterminate, and the type of each element is specified by a template parameter, so how does a tuple do that? The answer is to use a mutable parameter template. In C + +, we have used the printf function, whose arguments are mutable, and also allow the parameters of the template to be mutable in c++11. As an example, the following code is the number of arguments

All right, here we go, Mayuyu. Implements a print function that represents all values of the output variable parameter list. As follows

More information: please poke here

http://en.cppreference.com/w/cpp/utility/tuple

Tuple and variable parameter templates in c++11

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.