Provides an interface for concept checking. More...
Modules | |
Basic concepts submodule | |
Concepts involving constructibility and operational semantics. | |
Container concepts submodule | |
Concepts involving the standard C++ containers. | |
Function concepts submodule | |
Concepts involving functions. | |
Iterator concepts submodule | |
Concepts involving iterators. | |
Functions | |
template<typename T , template< typename...> class... Concepts> | |
constexpr bool | gears::concepts::require () |
Asserts that a type meets concepts provided. More... | |
This module is the basic implementation of Concepts that were supposed to appear in C++11 but didn't make it due to time constraints. It doesn't support axioms, concept maps, or any of the fancy stuff but provides enough syntactic sugar for the SFINAE part of the concepts proposal.
Concepts are split into two categories, Unary and Binary. A Unary Concept is defined as a concept that takes in a single type. A Binary Concept is a concept that takes in two types. Most of the time the second type is optional, this depends on the Concept. Sometimes a concept is not part of these categories, this makes the concept uncategorised. An example of this is Constructible.
Just like the Concepts themselves are split into different categories, the Concepts module itself is split into different categories which include:
The usage of Concepts is simple, most of which needs one function to assert your concepts.
Example:
constexpr bool gears::concepts::require | ( | ) |
The place for requires
is best inside functions rather than classes. As this function returns a boolean, it isn't possible to put it in its own line for template classes. For example, the following won't work:
This is because this function returns a boolean. Consider using the Require
statement instead:
T | Type to check concepts for |
Concepts... | Unary concepts to assert. |
true
, this value should probably be ignored as it is only there for constexpr
status. Definition at line 98 of file concepts/alias.hpp.