In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the concept of TS in C++". In the operation of practical cases, many people will encounter such a dilemma, so 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.24: use tag classes or features to distinguish concepts that are only semantically different
Reason (reason)
Two concepts requiring the same syntax but having different semantics leads to ambiguity unless the programmer differentiates them.
Two concepts have the same grammatical requirements but different semantics can lead to ambiguity unless programmers can distinguish between them.
Example (using TS concepts) (example (using TS concept))
Template / / iterator providing random access
Concept bool RA_iter =...
Template / / iterator providing random access to contiguous data
Concept bool Contiguous_iter =
RA_iter & & is_contiguous::value; / / using is_contiguous trait
The programmer (in a library) must define is_contiguous (a trait) appropriately.
Programmers (in library code) must define is_contiguous (characteristics) properly.
Wrapping a tag class into a concept leads to a simpler expression of this idea:
Sealing a tag class into a concept makes it easier to express an idea.
Template concept Contiguous = is_contiguous::value
Template
Concept bool Contiguous_iter = RA_iter & & Contiguous
The programmer (in a library) must define is_contiguous (a trait) appropriately.
Programmers (in library code) must define is_contiguous (characteristics) properly.
Note (Note)
Traits can be trait classes or type traits. These can be user-defined or standard-library ones. Prefer the standard-library ones.
The expression of features can be realized by giving you feature classes and type features. They can be user-defined or provided by standard libraries. The standard library provides a better way.
Enforcement (implementation recommendations)
The compiler flags ambiguous use of identical concepts.
The compiler should mark confusing usage that wants to define exactly the same concept.
Flag the definition of identical concepts.
Tag exactly the same conceptual definition.
This is the end of the introduction to "how to use the concept of TS in C++". 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
© 2024 shulou.com SLNews company. All rights reserved.