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