In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the new features of Category 11". In daily operation, I believe many people have doubts about the new features of Craft 11. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions about "what are the new features of Craft 11"! Next, please follow the editor to study!
Auto & decltype
The first thing to mention about the new features of Clover 11 must be type derivation, which introduces the keywords auto and decltype, which can be used to derive the type of variable or expression at compile time, making it easy for developers to code and simplify the code.
Auto: let the compiler derive the type of the variable at the compiler, and you can derive the type of the variable from the type to the right of =.
Auto a = 10; / / 10 is int, and it can be deduced automatically that an is int.
Decltype: as opposed to auto, it is used to derive variable types, while decltype is used to derive expression types, which are only used by the compiler to parse the types of expressions, which actually do not operate.
Cont int& I = 1; int a = 2; decltype (I) b = 2; / / b is const int&
For a detailed introduction to auto and decltype, please see: get through the knowledge points of auto and decltype in Craft 11.
Left value and right value
It is well known that a right value reference has been added to Category 11, which involves a lot of concepts:
Left value: something with an address and a name is the left value.
Right value: something without a name that cannot take an address is the right value.
Pure right value: temporary variables generated by operation expressions, original literals not associated with objects, temporary variables returned by non-references, lambda expressions, and so on are all pure right values.
Dead value: can be understood as the value to be destroyed.
Left value reference: the type that references the left value.
Right value reference: the type that references the right value.
Mobile semantics: transfer of ownership of resources, similar to the meaning of transfer or resource theft, for that resource, to own, others no longer own and will no longer use.
Perfect forwarding: you can write a function template that accepts arbitrary arguments and forward it to other functions, and the target function will receive exactly the same arguments as the forwarding function.
Return value optimization: when the function needs to return an object instance, a temporary object will be created and the target object will be copied to the temporary object by copying the constructor. Here, the copy constructor and destructor will be superfluously called. There is a cost, and through the return value optimization, the C++ standard allows you to omit these copy constructors.
For a detailed introduction here, please see: left value reference, right value reference, mobile semantics, perfect forwarding. What you know and what you don't know is here.
List initialization
You can initialize the object by adding the initialization list directly after the variable name in Category 11. For a detailed introduction, you must read this article: learn how to initialize the list of variables.
Std::function & std::bind & lambda expression
New wrappers such as std::function, std::bind and lambda expressions have been added to censor 11 to make function calls more convenient. For more information, please see: fix the new features std::function and lambda expressions of cymbals 11.
Improvement of template
Category 11 has some detailed improvements to the template:
The right angle bracket of the template
Alias of the template
Default template parameters for function templates
For more information, please see the template improvement of Clipper 11.
Concurrence
A lot of good things have been introduced about concurrency, including:
Std::thread correlation
Std::mutex correlation
Std::lock correlation
Std::atomic correlation
Std::call_once correlation
Volatile correlation
Std::condition_variable correlation
Std::future correlation
Async correlation
For a detailed introduction, please see: all the knowledge points related to the threading of the new features of cantilever 11.
The thread pool and timer, which are also implemented by clocking 11, can be seen here:
Revised version of the format for the implementation of C++ thread pool
Revised format of the implementation of C++ timer
Intelligent pointer
Many people say it is particularly difficult, probably partly because C++ 's memory management, unlike java, which is dynamically managed by virtual machines, may cause memory leaks during program running. However, this kind of problem can actually be solved through the smart pointers introduced by cymbal 11. On the contrary, I still think this kind of memory management is still the advantage of C++ language, because it is all in the grasp.
Three kinds of smart pointers have been introduced in caterpillar 11:
Std::shared_ptr
Std::weak_ptr
Std::unique_ptr
For more information, please see: smart pointers for the new features of cantilever 11
Range-based for loop
Look directly at the code.
Vector vec; for (auto iter = vec.begin (); iter! = vec.end (); iter++) {/ / before cantilever 11 cout
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.