Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the concept of C++ single type parameter?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the concept of C++ single-type parameter", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "what is the concept of C++ single-type parameter"!

T.13: for simple, single-type parameter concepts, it is better to use abbreviations

Reason (reason)

Readability. Direct expression of an idea.

Readability. Express your thoughts directly.

Example (using TS concepts) example (using TS concepts)

To say "T is Sortable":

To express "T is a sortable type":

Template / / Correct but verbose: "The parameter is

/ / requires Sortable / / of type T which is the name of a type

Void sort (T &); / / that is Sortable "

Template / / Better (assuming support for concepts): "The parameter is of type T

Void sort (T &); / / which is Sortable "

Void sort (Sortable&); / / Best (assuming support for concepts): "The parameter is Sortable"

The shorter versions better match the way we speak. Note that many templates don't need to use the template keyword.

The shorter version is more in line with what we want to express. Note that many templates do not need to use template keywords.

Note (Note)

"Concepts" are defined in an ISO Technical Specification: concepts. A draft of a set of standard-library concepts can be found in another ISO TS: ranges Concepts are supported in GCC 6.1 and later. Consequently, we comment out uses of concepts in examples; that is, we use them as formalized comments only. If you use a compiler that supports concepts (e.g., GCC 6.1 or later), you can remove the / /

The "concept" is defined in the ISO technical specification concepts. A preliminary version of a set of standard libraries concepts can be found in another ISO technical specification: ranges. GCC6.1 will support concepts in the future. So we comment out the parts that use concepts in the example code; that is, we just use them as standard comments. If you use a later version of GCC6.1, you can open the comments.

Enforcement (implementation recommendations)

Not feasible in the short term when people convert from the and notation.

If people turn from and notation, it is not appropriate to use abbreviations.

Later, flag declarations that first introduce a typename and then constrain it with a simple, single-type-argument concept.

Subsequently, the tag introduces the type name for the first time and immediately uses a simple, single-type concept to constrain it.

At this point, I believe that everyone on the "C++ single-type parameter concept is what" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report