How does C++ realize that the template parameters are at least regular or semi-normal?
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!