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

How does C++ realize that the template parameters are at least regular or semi-normal?

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

Share

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

This article mainly explains "how C++ realizes that the template parameters are at least formal or semi-formal". The content in the article is simple and clear and easy to learn and understand. let's study and learn "C++ how to achieve template parameters are at least formal or semi-formal"!

T.46: template parameters are required to be at least normal or semi-normal

Reason (reason)

Readability. Preventing surprises and errors. Most uses support that anyway.

Readability. Prevent unexpected code and errors. Anyway, many uses already support this.

Example (sample)

Class X {

Public:

Explicit X (int)

X (const X &); / / copy

X operator= (const X &)

X (X &) noexcept; / / move

X & operator= (X &) noexcept

~ X ()

/ /... No more constructors...

}

X x {1}; / / fine

X y = x; / / fine

Std::vector v (10); / / error: no default constructorNote (note)

Semiregular requires default constructible.

Semi-formal requirements can be constructed by default.

Enforcement (implementation recommendations)

Flag types that are not at least SemiRegular.

Tags types that are not even implemented by semi-normal.

Thank you for your reading, the above is the "C++ how to achieve template parameters are at least formal or semi-formal" content, after the study of this article, I believe you on C++ how to achieve template parameters are at least formal or semi-formal this problem has a deeper understanding, the specific use of needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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