Exploring requires expressions
A requires expression may be a complex expression, as seen earlier in the example with the container concept. The actual form of a requires expression is very similar to function syntax and is as follows:
requires (parameter-list) { requirement-seq }
The parameter-list
is a comma-separated list of parameters. The only difference from a function declaration is that default values are not allowed. However, the parameters that are specified in this list do not have storage, linkage, or lifetime. The compiler does not allocate any memory for them; they are only used to define requirements. However, they do have a scope, and that is the closing curly brace of the requires expression.
The requirements-seq
is a sequence of requirements. Each such requirement must end with a semicolon, like any statement in C++. There are four types of requirements:
- Simple requirements
- Type requirements
- Compound requirements
- Nested requirements ...