Skip to content

Commit cfb4e28

Browse files
author
Dawn Perchik
committed
P1084R2 Today’s return-type-requirements Are Insufficient
[expr.prim.req.compound] Renamed C5 to C3 in remaining example.
1 parent 12935b8 commit cfb4e28

File tree

1 file changed

+48
-61
lines changed

1 file changed

+48
-61
lines changed

source/expressions.tex

Lines changed: 48 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@
26002600
\begin{bnf}
26012601
\nontermdef{return-type-requirement}\br
26022602
trailing-return-type\br
2603-
\terminal{->} \opt{cv-qualifier-seq} constrained-parameter \opt{cv-qualifier-seq} \opt{abstract-declarator}
2603+
qualified-concept-name
26042604
\end{bnf}
26052605

26062606
\pnum
@@ -2610,45 +2610,51 @@
26102610
semantic properties proceed in the following order:
26112611

26122612
\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}
26522658
\end{itemize}
26532659

26542660
\begin{example}
@@ -2675,32 +2681,13 @@
26752681
\tcode{typename T::inner}.
26762682

26772683
\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 =
26982685
requires(T x) {
26992686
{g(x)} noexcept;
27002687
};
27012688
\end{codeblock}
27022689

2703-
The \grammarterm{compound-requirement} in \tcode{C5}
2690+
The \grammarterm{compound-requirement} in \tcode{C3}
27042691
requires that \tcode{g(x)} is a valid expression and
27052692
that \tcode{g(x)} is non-throwing.
27062693
\end{example}

0 commit comments

Comments
 (0)