From 81e37c0a2af08ca5eca8e37a48f8266462d0f841 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 12 Nov 2018 13:37:52 -0800 Subject: [PATCH 1/3] P1084R2 Today's return-type-requirements Are Insufficient Language-side changes. [expr.prim.req.compound] Renamed C5 to C3 in remaining example. --- source/expressions.tex | 84 +++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 32da0e4f2d..5a3e1d27c3 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2597,7 +2597,7 @@ \begin{bnf} \nontermdef{return-type-requirement}\br trailing-return-type\br - \terminal{->} \opt{cv-qualifier-seq} constrained-parameter \opt{cv-qualifier-seq} \opt{abstract-declarator} + \terminal{->} qualified-concept-name \end{bnf} \pnum @@ -2607,44 +2607,55 @@ semantic properties proceed in the following order: \begin{itemize} -\item Substitution of template arguments (if any) +\item +Substitution of template arguments (if any) into the \grammarterm{expression} is performed. -\item If the \tcode{noexcept} specifier is present, +\item +If the \tcode{noexcept} specifier is present, \tcode{E} shall not be a potentially-throwing expression\iref{except.spec}. -\item If the \grammarterm{return-type-requirement} is present, then: +\item +If the \grammarterm{return-type-requirement} is present, then: \begin{itemize} -\item Substitution of template arguments (if any) +\item +Substitution of template arguments (if any) into the \grammarterm{return-type-requirement} is performed. -\item If the \grammarterm{return-type-requirement} is a -\grammarterm{trailing-return-type}, +\item +If the \grammarterm{return-type-requirement} is a +\grammarterm{trailing-return-type}\iref{dcl.decl}, %%% FIXME: is -> shall be \tcode{E} is implicitly convertible to the type named by the \grammarterm{trailing-return-type}. If conversion fails, the enclosing \grammarterm{requires-expression} is \tcode{false}. -\item If the \grammarterm{return-type-requirement} -starts with a \grammarterm{constrained-parameter}\iref{temp.param}, -the \grammarterm{expression} is deduced against -an invented function template \tcode{F} -using the rules in \ref{temp.deduct.call}. -\tcode{F} is a \tcode{void} function template -with a single type template parameter \tcode{T} -declared with the \grammarterm{constrained-parameter}. -A \grammarterm{cv-qualifier-seq} \cv{} is formed -as the union of \tcode{const} and \tcode{volatile} specifiers -around the \grammarterm{constrained-parameter}. -\tcode{F} has a single parameter -whose \grammarterm{type-specifier} is \cv{}~\tcode{T} -followed by the \grammarterm{abstract-declarator}. -%%% FIXME: Remove this; if deduction fails, the construct should -%%% be ill-formed. -If deduction fails, -the enclosing \grammarterm{requires-expression} is \tcode{false}. +\item +If the \grammarterm{return-type-requirement} is +a \grammarterm{qualified-concept-name}\iref{temp.param} of the form +\opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name}, +the concept it denotes shall be satisfied with +\tcode{decltype((E))} as its sole argument. +If the \grammarterm{return-type-requirement} is +a \grammarterm{qualified-concept-name} of the form +\opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name} +\tcode{<} \opt{\grammarterm{template-argument-list}} \tcode{>}, +the concept it denotes shall be satisfied with +\tcode{decltype((E))} as its first argument and with +the elements, in the order listed, of +the \grammarterm{template-argument-list} +comprising the concept's subsequent arguments. +\begin{note} +Thus, requirements of the form +\tcode{\{ E \} -> Concept;} or of the form +\tcode{\{ E \} -> Concept<>;} are equivalent to +\tcode{E; requires Concept;} +while a requirements of the form +\tcode{\{ E \} -> Concept;} is equivalent to +\tcode{E; requires Concept;}. +\end{note} \end{itemize} \end{itemize} @@ -2672,32 +2683,13 @@ \tcode{typename T::inner}. \begin{codeblock} -template concept C3 = requires (T t, U u) { - t == u; -}; -template concept C4 = requires(T x) { - {*x} -> C3 const&; -}; -\end{codeblock} -The \grammarterm{compound-requirement} -requires that \tcode{*x} be deduced -as an argument for the invented function: -\begin{codeblock} -template X> void f(X const&); -\end{codeblock} -In this case, deduction only succeeds if -an expression of the type deduced for \tcode{X} -can be compared to an \tcode{int} -with the \tcode{==} operator. - -\begin{codeblock} -template concept C5 = +template concept C3 = requires(T x) { {g(x)} noexcept; }; \end{codeblock} -The \grammarterm{compound-requirement} in \tcode{C5} +The \grammarterm{compound-requirement} in \tcode{C3} requires that \tcode{g(x)} is a valid expression and that \tcode{g(x)} is non-throwing. \end{example} From 35ae559349c04704fa3e4885af2850ecc3c3fc3b Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sat, 17 Nov 2018 12:57:17 -0800 Subject: [PATCH 2/3] P1084R2 Today's return-type-requirements Are Insufficient Library-side changes: replace requires { E; requires Concept; } with requires { { E } -> Concept; } --- source/concepts.tex | 61 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/source/concepts.tex b/source/concepts.tex index defd96dcb7..b35446a51e 100644 --- a/source/concepts.tex +++ b/source/concepts.tex @@ -479,8 +479,7 @@ is_lvalue_reference_v && CommonReference&, const remove_reference_t&> && requires(LHS lhs, RHS&& rhs) { - lhs = std::forward(rhs); - requires Same(rhs)), LHS>; + { lhs = std::forward(rhs) } -> Same; }; \end{itemdecl} @@ -757,19 +756,19 @@ requires(const remove_reference_t& b1, const remove_reference_t& b2, const bool a) { requires ConvertibleTo&, bool>; - !b1; requires ConvertibleTo; - b1 && a; requires Same; - b1 || a; requires Same; - b1 && b2; requires Same; - a && b2; requires Same; - b1 || b2; requires Same; - a || b2; requires Same; - b1 == b2; requires ConvertibleTo; - b1 == a; requires ConvertibleTo; - a == b2; requires ConvertibleTo; - b1 != b2; requires ConvertibleTo; - b1 != a; requires ConvertibleTo; - a != b2; requires ConvertibleTo; + { !b1 } -> ConvertibleTo; + { b1 && a } -> Same; + { b1 || a } -> Same; + { b1 && b2 } -> Same; + { a && b2 } -> Same; + { b1 || b2 } -> Same; + { a || b2 } -> Same; + { b1 == b2 } -> ConvertibleTo; + { b1 == a } -> ConvertibleTo; + { a == b2 } -> ConvertibleTo; + { b1 != b2 } -> ConvertibleTo; + { b1 != a } -> ConvertibleTo; + { a != b2 } -> ConvertibleTo; }; \end{itemdecl} @@ -811,10 +810,10 @@ concept @\placeholder{weakly-equality-comparable-with}@ = // \expos requires(const remove_reference_t& t, const remove_reference_t& u) { - t == u; requires Boolean; - t != u; requires Boolean; - u == t; requires Boolean; - u != t; requires Boolean; + { t == u } -> Boolean; + { t != u } -> Boolean; + { u == t } -> Boolean; + { u != t } -> Boolean; }; \end{itemdecl} @@ -888,10 +887,10 @@ EqualityComparable && requires(const remove_reference_t& a, const remove_reference_t& b) { - a < b; requires Boolean; - a > b; requires Boolean b)>; - a <= b; requires Boolean; - a >= b; requires Boolean= b)>; + { a < b } -> Boolean; + { a > b } -> Boolean; + { a <= b } -> Boolean; + { a >= b } -> Boolean; }; \end{itemdecl} @@ -925,14 +924,14 @@ EqualityComparableWith && requires(const remove_reference_t& t, const remove_reference_t& u) { - t < u; requires Boolean; - t > u; requires Boolean u)>; - t <= u; requires Boolean; - t >= u; requires Boolean= u)>; - u < t; requires Boolean; - u > t; requires Boolean t)>; - u <= t; requires Boolean; - u >= t; requires Boolean= t)>; + { t < u } -> Boolean; + { t > u } -> Boolean; + { t <= u } -> Boolean; + { t >= u } -> Boolean; + { u < t } -> Boolean; + { u > t } -> Boolean; + { u <= t } -> Boolean; + { u >= t } -> Boolean; }; \end{itemdecl} From fb22bbd60aba1f3aaf9288ab08a7feeb8e4c0101 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 23 Nov 2018 19:51:28 -0800 Subject: [PATCH 3/3] [expr.prim.req.compound] Change "is" to "has a" when refering to grammar terms. --- source/expressions.tex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 5a3e1d27c3..6a0c8ae939 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2633,12 +2633,12 @@ is \tcode{false}. \item -If the \grammarterm{return-type-requirement} is +If the \grammarterm{return-type-requirement} has a \grammarterm{qualified-concept-name}\iref{temp.param} of the form \opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name}, the concept it denotes shall be satisfied with \tcode{decltype((E))} as its sole argument. -If the \grammarterm{return-type-requirement} is +If the \grammarterm{return-type-requirement} has a \grammarterm{qualified-concept-name} of the form \opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name} \tcode{<} \opt{\grammarterm{template-argument-list}} \tcode{>},