cpp/language/requires

Yields a prvalue expression of type that describes the constraints.

Syntax
{{par|{{spar|parameter-list}}|a comma-separated list of parameters like in a function declaration, except that default arguments are not allowed and it cannot end with an ellipsis (other than one signifying a pack expansion). These parameters have no storage, linkage or lifetime, and are only used to assist in specifying requirements. These parameters are in scope until the closing {{ttb|}}} of the .}}

Explanation
Requirements may refer to the template parameters that are in scope, to the local parameters introduced in the, and to any other declarations that are visible from the enclosing context.

The substitution of template arguments into a requires-expression used in a declaration of a may result in the formation of invalid types or expressions in its requirements, or the violation of semantic constraints of those requirements. In such cases, the requires-expression evaluates to and does not cause the program to be ill-formed. The substitution and semantic constraint checking proceeds in lexical order and stops when a condition that determines the result of the requires-expression is encountered. If substitution (if any) and semantic constraint checking succeed, the requires-expression evaluates to.

If a substitution failure would occur in a requires-expression for every possible template argument, the program is ill-formed, no diagnostic required:

If a requires-expression contains invalid types or expressions in its requirements, and it does not appear within the declaration of a, then the program is ill-formed.

Simple requirements
A simple requirement is an arbitrary expression statement that does not start with the keyword. It asserts that the expression is valid. The expression is an unevaluated operand; only language correctness is checked.

A requirement that starts with the keyword is always interpreted as a nested requirement. Thus a simple requirement cannot start with an unparenthesized requires-expression.

Type requirements
A type requirement is the keyword followed by a type name, optionally qualified. The requirement is that the named type is valid: this can be used to verify that a certain named nested type exists, or that a class template specialization names a type, or that an alias template specialization names a type. A type requirement naming a class template specialization does not require the type to be complete.

Compound requirements
A compound requirement has the form

and asserts properties of the named expression. Substitution and semantic constraint checking proceeds in the following order: @1@ Template arguments (if any) are substituted into ; @2@ If is used,  must not be potentially throwing; @3@ If is present, then:
 * @a@ Template arguments are substituted into the ;
 * @b@ must satisfy the constraint imposed by the . Otherwise, the enclosing requires-expression is.

Nested requirements
A nested requirement has the form

It can be used to specify additional constraints in terms of local parameters. The must be satisfied by the substituted template arguments, if any. Substitution of template arguments into a nested requirement causes substitution into the only to the extent needed to determine whether the  is satisfied.

Note
The keyword is also used to introduce requires clauses.