|
484 | 484 | \pnum
|
485 | 485 | An \grammarterm{id-expression}
|
486 | 486 | that denotes the specialization of a concept~(\ref{temp.concept})
|
487 |
| -results in a prvalue of type \tcode{bool}. |
| 487 | +results in a prvalue of type \tcode{bool}. |
488 | 488 | The expression is \tcode{true} if
|
489 | 489 | the concept's normalized~(\ref{temp.constr.decl})
|
490 | 490 | \grammarterm{constraint-expression}
|
|
1513 | 1513 | \indextext{expression!requires|(}%
|
1514 | 1514 |
|
1515 | 1515 | \pnum
|
1516 |
| -A \grammarterm{requires-expression} provides a concise way to express |
| 1516 | +A \grammarterm{requires-expression} provides a concise way to express |
1517 | 1517 | requirements on template arguments
|
1518 | 1518 | that can be checked by name lookup~(\ref{basic.lookup})
|
1519 | 1519 | or by checking properties of types and expressions.
|
|
1564 | 1564 | {*i} -> const typename T::type&;
|
1565 | 1565 | };
|
1566 | 1566 | \end{codeblock}
|
1567 |
| -A \grammarterm{requires-expression} can also be used in a |
1568 |
| -\grammarterm{requires-clause} (Clause~\ref{temp}) as a way of writing ad hoc |
| 1567 | +A \grammarterm{requires-expression} can also be used in a |
| 1568 | +\grammarterm{requires-clause} (Clause~\ref{temp}) as a way of writing ad hoc |
1569 | 1569 | constraints on template arguments such as the one below:
|
1570 | 1570 | \begin{codeblock}
|
1571 | 1571 | template<typename T>
|
1572 | 1572 | requires requires (T x) { x + x; }
|
1573 | 1573 | T add(T a, T b) { return a + b; }
|
1574 | 1574 | \end{codeblock}
|
1575 |
| -The first \tcode{requires} introduces the |
| 1575 | +The first \tcode{requires} introduces the |
1576 | 1576 | \grammarterm{requires-clause}, and the second
|
1577 | 1577 | introduces the \grammarterm{requires-expression}.
|
1578 | 1578 | \end{example}
|
1579 | 1579 |
|
1580 | 1580 | \pnum
|
1581 | 1581 | A \grammarterm{requires-expression} may introduce local parameters using a
|
1582 |
| -\grammarterm{parameter-declaration-clause}~(\ref{dcl.fct}). |
1583 |
| -A local parameter of a \grammarterm{requires-expression} shall not have a |
| 1582 | +\grammarterm{parameter-declaration-clause}~(\ref{dcl.fct}). |
| 1583 | +A local parameter of a \grammarterm{requires-expression} shall not have a |
1584 | 1584 | default argument.
|
1585 | 1585 | Each name introduced by a local parameter is in scope from the point
|
1586 | 1586 | of its declaration until the closing brace of the
|
1587 | 1587 | \grammarterm{requirement-body}.
|
1588 | 1588 | These parameters have no linkage, storage, or lifetime; they are only used
|
1589 | 1589 | as notation for the purpose of defining \grammarterm{requirement}{}s.
|
1590 |
| -The \grammarterm{parameter-declaration-clause} of a |
| 1590 | +The \grammarterm{parameter-declaration-clause} of a |
1591 | 1591 | \grammarterm{requirement-parameter-list}
|
1592 | 1592 | shall not terminate with an ellipsis.
|
1593 | 1593 | \begin{example}
|
1594 | 1594 | \begin{codeblock}
|
1595 | 1595 | template<typename T>
|
1596 | 1596 | concept C = requires(T t, ...) { // error: terminates with an ellipsis
|
1597 |
| - t; |
| 1597 | + t; |
1598 | 1598 | };
|
1599 | 1599 | \end{codeblock}
|
1600 | 1600 | \end{example}
|
|
1603 | 1603 | \indextext{requirement}%
|
1604 | 1604 | The \grammarterm{requirement-body} contains
|
1605 | 1605 | a sequence of \grammarterm{requirement}{}s.
|
1606 |
| -These \grammarterm{requirement}{}s may refer to local |
1607 |
| -parameters, template parameters, and any other declarations visible from the |
1608 |
| -enclosing context. |
| 1606 | +These \grammarterm{requirement}{}s may refer to local |
| 1607 | +parameters, template parameters, and any other declarations visible from the |
| 1608 | +enclosing context. |
1609 | 1609 |
|
1610 | 1610 | \pnum
|
1611 |
| -The substitution of template arguments into a \grammarterm{requires-expression} |
| 1611 | +The substitution of template arguments into a \grammarterm{requires-expression} |
1612 | 1612 | may result in the formation of invalid types or expressions in its
|
1613 | 1613 | requirements or the violation of the semantic constraints of those requirements.
|
1614 | 1614 | In such cases, the \grammarterm{requires-expression} evaluates to \tcode{false};
|
|
1623 | 1623 | its requirements, and it does not appear within the declaration of a templated
|
1624 | 1624 | entity, then the program is ill-formed.
|
1625 | 1625 | \end{note}
|
1626 |
| -If the substitution of template arguments into a \grammarterm{requirement} |
1627 |
| -would always result in a substitution failure, the program is ill-formed; |
| 1626 | +If the substitution of template arguments into a \grammarterm{requirement} |
| 1627 | +would always result in a substitution failure, the program is ill-formed; |
1628 | 1628 | no diagnostic required.
|
1629 | 1629 | \begin{example}
|
1630 | 1630 | \begin{codeblock}
|
|
1687 | 1687 | \end{example}
|
1688 | 1688 |
|
1689 | 1689 | \pnum
|
1690 |
| -A type requirement that names a class template specialization |
| 1690 | +A type requirement that names a class template specialization |
1691 | 1691 | does not require that type to be complete~(\ref{basic.types}).
|
1692 | 1692 |
|
1693 | 1693 | \rSec3[expr.prim.req.compound]{Compound requirements}
|
1694 | 1694 | \indextext{requirement!compound}%
|
1695 |
| - |
| 1695 | + |
1696 | 1696 | \begin{bnf}
|
1697 | 1697 | \nontermdef{compound-requirement}\br
|
1698 | 1698 | \terminal{\{} expression \terminal{\}} \terminal{noexcept}\opt{} return-type-requirement\opt{} \terminal{;}
|
|
1723 | 1723 | \item Substitution of template arguments (if any)
|
1724 | 1724 | into the \grammarterm{return-type-requirement} is performed.
|
1725 | 1725 |
|
1726 |
| -\item If the \grammarterm{return-type-requirement} is a |
| 1726 | +\item If the \grammarterm{return-type-requirement} is a |
1727 | 1727 | \grammarterm{trailing-return-type},
|
1728 | 1728 | %%% FIXME: is -> shall be
|
1729 | 1729 | \tcode{E} is implicitly convertible to
|
|
1738 | 1738 | using the rules in \ref{temp.deduct.call}.
|
1739 | 1739 | \tcode{F} is a \tcode{void} function template
|
1740 | 1740 | with a single type template parameter \tcode{T}
|
1741 |
| -declared with the \grammarterm{constrained-parameter}. |
| 1741 | +declared with the \grammarterm{constrained-parameter}. |
1742 | 1742 | A \grammarterm{cv-qualifier-seq} \cv{} is formed
|
1743 | 1743 | as the union of \tcode{const} and \tcode{volatile} specifiers
|
1744 | 1744 | around the \grammarterm{constrained-parameter}.
|
|
1758 | 1758 | {x++};
|
1759 | 1759 | };
|
1760 | 1760 | \end{codeblock}
|
1761 |
| -The \grammarterm{compound-requirement} in \tcode{C1} |
| 1761 | +The \grammarterm{compound-requirement} in \tcode{C1} |
1762 | 1762 | requires that \tcode{x++} is a valid expression.
|
1763 | 1763 | It is equivalent to a \grammarterm{simple-requirement}
|
1764 | 1764 | with the same \grammarterm{expression}.
|
|
1769 | 1769 | };
|
1770 | 1770 | \end{codeblock}
|
1771 | 1771 |
|
1772 |
| -The \grammarterm{compound-requirement} in \tcode{C2} |
| 1772 | +The \grammarterm{compound-requirement} in \tcode{C2} |
1773 | 1773 | requires that \tcode{*x} is a valid expression,
|
1774 | 1774 | that \tcode{typename T::inner} is a valid type, and
|
1775 | 1775 | that \tcode{*x} is implicitly convertible to
|
|
1801 | 1801 | };
|
1802 | 1802 | \end{codeblock}
|
1803 | 1803 |
|
1804 |
| -The \grammarterm{compound-requirement} in \tcode{C5} |
| 1804 | +The \grammarterm{compound-requirement} in \tcode{C5} |
1805 | 1805 | requires that \tcode{g(x)} is a valid expression and
|
1806 | 1806 | that \tcode{g(x)} is non-throwing.
|
1807 | 1807 | \end{example}
|
|
1835 | 1835 | \end{example}
|
1836 | 1836 |
|
1837 | 1837 | \pnum
|
1838 |
| -A local parameter shall only appear as an unevaluated operand |
| 1838 | +A local parameter shall only appear as an unevaluated operand |
1839 | 1839 | (Clause~\ref{expr}) within the \grammarterm{constraint-expression}.
|
1840 | 1840 | \begin{example}
|
1841 | 1841 | \begin{codeblock}
|
|
0 commit comments