In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "what is C++ minimization template's dependence on context". Many people will encounter this dilemma in the operation of actual cases. then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
T.60: minimize the template's dependency on context
Reason (reason)
Eases understanding. Minimizes errors from unexpected dependencies. Eases tool creation.
Make it easier to understand. Minimize errors caused by unexpected dependencies. Facilitate tool generation.
Example (sample)
Template
Void sort (C & c)
{
Std::sort (begin (c), end (c)); / / necessary and useful dependency
}
Template
Iter algo (Iter first, Iter last)
{
For (; first! = last; + + first) {
Auto x = sqrt (* first); / / potentially surprising dependency: which sqrt ()?
Helper (first, x); / / potentially surprising dependency:
/ / helper is chosen based on first and x
TT var = 7; / / potentially surprising dependency: which TT?
}
} Note (note)
Templates typically appear in header files so their context dependencies are more vulnerable to # include order dependencies than functions in .cpp files.
Templates usually appear in header files, and their context dependencies are more likely to be affected by the # include order than in CPP files.
Note (Note)
Having a template operate only on its arguments would be one way of reducing the number of dependencies to a minimum, but that would generally be unmanageable. For example, algorithms usually use other algorithms and invoke operations that do not exclusively operate on arguments. And don't get us started on macros!
Letting template operations only manipulate parameters is a way to minimize the number of dependencies. But that's usually not possible. For example, algorithms typically use other algorithms and invoke operations that cannot be exclusive to parameters.
This is the end of the content of "C++ minimization template's dependence on context". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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
1. Using jconsole2. Using jvisualVM--- to generate thread DUMP
© 2024 shulou.com SLNews company. All rights reserved.