Difference between revisions of "cpp/named req"
(links) |
(Added link to <type_traits>) |
||
Line 5: | Line 5: | ||
There was a proposal to include formal specification of concepts into the C++ language, so that the compiler could check the type requirements ''before'' template instantiation and in turn could produce much more sensible error messages in case a type did not fulfill the template requirements. This proposal was later dropped for various reasons. However, there are unofficial plans to add concepts to a future revision of the C++ language. | There was a proposal to include formal specification of concepts into the C++ language, so that the compiler could check the type requirements ''before'' template instantiation and in turn could produce much more sensible error messages in case a type did not fulfill the template requirements. This proposal was later dropped for various reasons. However, there are unofficial plans to add concepts to a future revision of the C++ language. | ||
+ | |||
+ | {{mark since c++11}} To check whether a type matches the requirements of a concept, the standard library provides a set of functions in [[cpp/types#Supported operations|<type_traits>]] | ||
{{dcl list begin}} | {{dcl list begin}} |
Revision as of 06:30, 11 March 2012
Concept is a term that describes a set of characteristics of a type. Concepts are a more convenient way to specify both what properties are expected from a type, and what properties a type has.
There was a proposal to include formal specification of concepts into the C++ language, so that the compiler could check the type requirements before template instantiation and in turn could produce much more sensible error messages in case a type did not fulfill the template requirements. This proposal was later dropped for various reasons. However, there are unofficial plans to add concepts to a future revision of the C++ language.
(since C++11) To check whether a type matches the requirements of a concept, the standard library provides a set of functions in <type_traits>
Basic concepts | |
specifies that type has default constructor (concept) | |
specifies that type has copy constructor (concept) | |
(C++11) |
specifies that type has move constructor (concept) |
specifies that type has copy assignment operator (concept) | |
(C++11) |
specifies that type can move assignment operator (concept) |