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 are the advantages of using the standard concept in C++

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "what are the advantages of using the standard concept of C++", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the advantages of using the standard concept of C++"?

T.11: use standard concepts whenever possible

Reason (reason)

"Standard" concepts (as provided by the GSL and the Ranges TS, and hopefully soon the ISO standard itself) save us the work of thinking up our own concepts, are better thought out than we can manage to do in a hurry, and improve interoperability.

The concept of "standards" (provided by GSL or Range technical specifications, and most likely ISO standards soon) can save us the work of designing concepts for our own use, and standard concepts will be better and more interchangeable than those we hastily designed.

Note (Note)

Unless you are creating a new generic library, most of the concepts you need will already be defined by the standard library

Unless you are developing a new generic library, most of the concepts you need should already be defined in the standard library and do not require additional design.

Example (using TS concepts) (instance (using TS concept))

Template

/ / don't define this: Sortable is in the GSL

Concept Ordered_container = Sequence & & Random_access & & Ordered

Void sort (Ordered_container& s)

This Ordered_container is quite plausible, but it is very similar to the Sortable concept in the GSL (and the Range TS). Is it better? Is it right? Does it accurately reflect the standard's requirements for sort? It is better and simpler just to use Sortable:

Ordered_container is quite reasonable, but it is very similar to the concept of Sortable in GSL (and RangeTS). Is it better to do this? Is this the right thing to do? Does it accurately reflect the standard requirements for sorting? It is simpler and better to use Sortable directly.

Void sort (Sortable& s); / / betterNote (note)

The set of "standard" concepts is evolving as we approach an ISO standard including concepts.

In the process of introducing the concept into the ISO standard, this set of "standard" concepts are also gradually developing.

Note (Note)

Designing a useful concept is challenging.

Designing a useful concept is a challenge.

Enforcement (implementation recommendations)

Hard.

It's hard

Look for unconstrained arguments, templates that use "unusual" / non-standard concepts, templates that use "homebrew" concepts without axioms.

Look for templates that use unconstrained parameters, templates that use "unusual" / non-standard concepts, and templates that use self-defined concepts that have not been well demonstrated.

Develop a concept-discovery tool (e.g.see an early experiment).

Design a tool for discovering concepts

At this point, I believe you have a deeper understanding of "what are the advantages of the standard concept of the use of C++?" you might as well do it in practice. 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