|
2600 | 2600 | \begin{bnf}
|
2601 | 2601 | \nontermdef{return-type-requirement}\br
|
2602 | 2602 | trailing-return-type\br
|
2603 |
| - \terminal{->} \opt{cv-qualifier-seq} constrained-parameter \opt{cv-qualifier-seq} \opt{abstract-declarator} |
| 2603 | + qualified-concept-name |
2604 | 2604 | \end{bnf}
|
2605 | 2605 |
|
2606 | 2606 | \pnum
|
|
2610 | 2610 | semantic properties proceed in the following order:
|
2611 | 2611 |
|
2612 | 2612 | \begin{itemize}
|
2613 |
| -\item Substitution of template arguments (if any) |
2614 |
| -into the \grammarterm{expression} is performed. |
2615 |
| - |
2616 |
| -\item If the \tcode{noexcept} specifier is present, |
2617 |
| -\tcode{E} shall not be a potentially-throwing expression\iref{except.spec}. |
2618 |
| - |
2619 |
| -\item If the \grammarterm{return-type-requirement} is present, then: |
2620 |
| - |
2621 |
| -\begin{itemize} |
2622 |
| -\item Substitution of template arguments (if any) |
2623 |
| -into the \grammarterm{return-type-requirement} is performed. |
2624 |
| - |
2625 |
| -\item If the \grammarterm{return-type-requirement} is a |
2626 |
| -\grammarterm{trailing-return-type}, |
2627 |
| -%%% FIXME: is -> shall be |
2628 |
| -\tcode{E} is implicitly convertible to |
2629 |
| -the type named by the \grammarterm{trailing-return-type}. |
2630 |
| -If conversion fails, the enclosing \grammarterm{requires-expression} |
2631 |
| -is \tcode{false}. |
2632 |
| - |
2633 |
| -\item If the \grammarterm{return-type-requirement} |
2634 |
| -starts with a \grammarterm{constrained-parameter}\iref{temp.param}, |
2635 |
| -the \grammarterm{expression} is deduced against |
2636 |
| -an invented function template \tcode{F} |
2637 |
| -using the rules in \ref{temp.deduct.call}. |
2638 |
| -\tcode{F} is a \tcode{void} function template |
2639 |
| -with a single type template parameter \tcode{T} |
2640 |
| -declared with the \grammarterm{constrained-parameter}. |
2641 |
| -A \grammarterm{cv-qualifier-seq} \cv{} is formed |
2642 |
| -as the union of \tcode{const} and \tcode{volatile} specifiers |
2643 |
| -around the \grammarterm{constrained-parameter}. |
2644 |
| -\tcode{F} has a single parameter |
2645 |
| -whose \grammarterm{type-specifier} is \cv{}~\tcode{T} |
2646 |
| -followed by the \grammarterm{abstract-declarator}. |
2647 |
| -%%% FIXME: Remove this; if deduction fails, the construct should |
2648 |
| -%%% be ill-formed. |
2649 |
| -If deduction fails, |
2650 |
| -the enclosing \grammarterm{requires-expression} is \tcode{false}. |
2651 |
| -\end{itemize} |
| 2613 | +\item |
| 2614 | + Substitution of template arguments (if any) |
| 2615 | + into the \grammarterm{expression} is performed. |
| 2616 | +\item |
| 2617 | + If the \tcode{noexcept} specifier is present, |
| 2618 | + \tcode{E} shall not be a potentially-throwing expression\iref{except.spec}. |
| 2619 | +\item |
| 2620 | + If the \grammarterm{return-type-requirement} is present, then: |
| 2621 | + \begin{itemize} |
| 2622 | + \item |
| 2623 | + Substitution of template arguments (if any) |
| 2624 | + into the \grammarterm{return-type-requirement} is performed. |
| 2625 | + \item |
| 2626 | + If the \grammarterm{return-type-requirement} is a |
| 2627 | + \grammarterm{trailing-return-type}\iref{dcl.decl}, |
| 2628 | + %%% FIXME: is -> shall be |
| 2629 | + \tcode{E} is implicitly convertible to |
| 2630 | + the type named by the \grammarterm{trailing-return-type}. |
| 2631 | + If conversion fails, the enclosing \grammarterm{requires-expression} |
| 2632 | + is \tcode{false}. |
| 2633 | + \item |
| 2634 | + If the \grammarterm{return-type-requirement} is |
| 2635 | + a \grammarterm{qualified-concept-name}\iref{temp.param} of the form |
| 2636 | + \opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name}, |
| 2637 | + the concept it denotes shall be satisfied with |
| 2638 | + \tcode{decltype((E))} as its sole argument. |
| 2639 | + If the \grammarterm{return-type-requirement} is |
| 2640 | + a \grammarterm{qualified-concept-name} of the form |
| 2641 | + \opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name} |
| 2642 | + \tcode{<} \opt{\grammarterm{template-argument-list}} \tcode{>}, |
| 2643 | + the concept it denotes shall be satisfied with |
| 2644 | + \tcode{decltype((E))} as its first argument and with |
| 2645 | + the elements, in the order listed, of |
| 2646 | + the \grammarterm{template-argument-list} |
| 2647 | + comprising the concept’s subsequent arguments. |
| 2648 | + \begin{note} |
| 2649 | + Thus, constraints of the form |
| 2650 | + \tcode{\{ E \} -> Concept;} or of the form |
| 2651 | + \tcode{\{ E \} -> Concept<>;} are equivalent to |
| 2652 | + \tcode{E; requires Concept<decltype((E))>;} |
| 2653 | + while a constraint of the form |
| 2654 | + \tcode{\{ E \} -> Concept<A$_1$, A$_2$, . . . , A$_n$>;} is equivalent to |
| 2655 | + \tcode{E; requires Concept<decltype((E)), A$_1$, A$_2$, ..., A$_n$>;}. |
| 2656 | + \end{note} |
| 2657 | + \end{itemize} |
2652 | 2658 | \end{itemize}
|
2653 | 2659 |
|
2654 | 2660 | \begin{example}
|
|
2675 | 2681 | \tcode{typename T::inner}.
|
2676 | 2682 |
|
2677 | 2683 | \begin{codeblock}
|
2678 |
| -template<typename T, typename U> concept C3 = requires (T t, U u) { |
2679 |
| - t == u; |
2680 |
| -}; |
2681 |
| -template<typename T> concept C4 = requires(T x) { |
2682 |
| - {*x} -> C3<int> const&; |
2683 |
| -}; |
2684 |
| -\end{codeblock} |
2685 |
| -The \grammarterm{compound-requirement} |
2686 |
| -requires that \tcode{*x} be deduced |
2687 |
| -as an argument for the invented function: |
2688 |
| -\begin{codeblock} |
2689 |
| -template<C3<int> X> void f(X const&); |
2690 |
| -\end{codeblock} |
2691 |
| -In this case, deduction only succeeds if |
2692 |
| -an expression of the type deduced for \tcode{X} |
2693 |
| -can be compared to an \tcode{int} |
2694 |
| -with the \tcode{==} operator. |
2695 |
| - |
2696 |
| -\begin{codeblock} |
2697 |
| -template<typename T> concept C5 = |
| 2684 | +template<typename T> concept C3 = |
2698 | 2685 | requires(T x) {
|
2699 | 2686 | {g(x)} noexcept;
|
2700 | 2687 | };
|
2701 | 2688 | \end{codeblock}
|
2702 | 2689 |
|
2703 |
| -The \grammarterm{compound-requirement} in \tcode{C5} |
| 2690 | +The \grammarterm{compound-requirement} in \tcode{C3} |
2704 | 2691 | requires that \tcode{g(x)} is a valid expression and
|
2705 | 2692 | that \tcode{g(x)} is non-throwing.
|
2706 | 2693 | \end{example}
|
|
0 commit comments