In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains how to use the tuple template of the Category 11 standard library. The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use the tuple template of the Craft 11 standard library.
What is tuple?
The author's English is general, before writing the article, first check the meaning of tuple, Baidu translation gives the result is: tuple, array. To be honest, I don't understand. Looking up the English dictionary again, the explanation given is:
A structure of data that has several parts .
This is easy to understand, which is a data structure with multiple parts.
Initialization
There are several ways to initialize tuple. The first is default initialization. In this case, each member of the tuple is initialized by default.
You can also specify values for individual members at initialization time. The first method in the following code uses the constructor of tuple, and the second way uses the initialization list.
Using the make_tuple function with the auto type indicator, you can also initialize tuple more succinctly.
Access tuple members
Once the object is created, you can access its members. The form of access is special, it is a function template. You may not be used to the form of code, but you just need to understand the following points.
The function argument is a tuple object.
The template parameter is the index of the member and must be of type const expression.
Although the template parameter also has a type of tuple object, because the compiler can infer from the tuple object, it does not actually require input.
The code is as follows:
The output results refer to the comments.
Get the number and type of members
If the generator and consumer of the tuple data are not in the same module, you may need to do some kind of check on the data, and you will probably want to know the number or type of members. Go straight to the code.
As you can see from the above code:
1. The input to the tuple object requires the type of the object, not the object itself.
two。 The type of member can be obtained using tuple_element or decltype in conjunction with get.
Thank you for your reading, the above is the content of "how to use the tuple template of the standard library tuple 11". After the study of this article, I believe you have a deeper understanding of how to use the template of the standard library tuple, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.