From cfb4e280089fd22d7b3e4715ae58a69ab0c0dbdf Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Mon, 12 Nov 2018 13:37:52 -0800 Subject: [PATCH 1/6] =?UTF-8?q?P1084R2=20Today=E2=80=99s=20return-type-req?= =?UTF-8?q?uirements=20Are=20Insufficient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [expr.prim.req.compound] Renamed C5 to C3 in remaining example. --- source/expressions.tex | 109 ++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 61 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 0d4993009c..c4c27ff138 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2600,7 +2600,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} + qualified-concept-name \end{bnf} \pnum @@ -2610,45 +2610,51 @@ semantic properties proceed in the following order: \begin{itemize} -\item Substitution of template arguments (if any) -into the \grammarterm{expression} is performed. - -\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: - -\begin{itemize} -\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}, -%%% 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}. -\end{itemize} +\item + Substitution of template arguments (if any) + into the \grammarterm{expression} is performed. +\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: + \begin{itemize} + \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}\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} 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, constraints of the form + \tcode{\{ E \} -> Concept;} or of the form + \tcode{\{ E \} -> Concept<>;} are equivalent to + \tcode{E; requires Concept;} + while a constraint of the form + \tcode{\{ E \} -> Concept;} is equivalent to + \tcode{E; requires Concept;}. + \end{note} + \end{itemize} \end{itemize} \begin{example} @@ -2675,32 +2681,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 2a38e296da021b628424e0de5a56e4e3f4eee096 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Thu, 15 Nov 2018 16:23:37 -0800 Subject: [PATCH 2/6] Fixup: P1084R2 Add missing "->" before qualified-concept-name. --- source/expressions.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/expressions.tex b/source/expressions.tex index c4c27ff138..373e600b94 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2600,7 +2600,7 @@ \begin{bnf} \nontermdef{return-type-requirement}\br trailing-return-type\br - qualified-concept-name + \terminal{->} qualified-concept-name \end{bnf} \pnum From 6ea0f72dd2f0e30b437f4d33e91b32411b8ad141 Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Thu, 15 Nov 2018 16:25:02 -0800 Subject: [PATCH 3/6] [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 373e600b94..193773f974 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2631,12 +2631,12 @@ If conversion fails, the enclosing \grammarterm{requires-expression} is \tcode{false}. \item - If the \grammarterm{return-type-requirement} is + If the \grammarterm{return-type-requirement} has a 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 a \grammarterm{qualified-concept-name} of the form \opt{\grammarterm{nested-name-specifier}} \grammarterm{concept-name} \tcode{<} \opt{\grammarterm{template-argument-list}} \tcode{>}, From 0af79b8ab4b3256d770e139555aad61bf843370c Mon Sep 17 00:00:00 2001 From: Dawn Perchik Date: Fri, 16 Nov 2018 12:33:47 -0800 Subject: [PATCH 4/6] [expr.prim.req.compound] Resolve conflicts in P1084R2 and P1141R2. Replace /qualified-concept-name/ with /type-constraint/ in grammar for /return-type-requirement/, and rewrite the new bullet for /return-type-requirement/ added in P1084R2 to use the term immediately-declared constraint introduced in P1141R2. --- source/expressions.tex | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/source/expressions.tex b/source/expressions.tex index 193773f974..00e981f446 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2600,7 +2600,7 @@ \begin{bnf} \nontermdef{return-type-requirement}\br trailing-return-type\br - \terminal{->} qualified-concept-name + \terminal{->} type-constraint \end{bnf} \pnum @@ -2631,20 +2631,12 @@ If conversion fails, the enclosing \grammarterm{requires-expression} is \tcode{false}. \item - If the \grammarterm{return-type-requirement} has a - 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} has a - 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. + If the \grammarterm{return-type-requirement} + is of the form \tcode{->} \grammarterm{type-constraint}, then + the contextually-determined type being constrained + is \tcode{decltype((E))}. + The immediately-declared constraint\iref(temp) of \tcode{decltype((E))} + shall be satisfied. \begin{note} Thus, constraints of the form \tcode{\{ E \} -> Concept;} or of the form From 5e22b242d8cb35e38ac4a6c5b9ee9391bc05acfb Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sat, 17 Nov 2018 13:18:41 -0800 Subject: [PATCH 5/6] [expr.prim.req.compound] Fixup: "\iref(temp)" should be "\iref{temp}" --- source/expressions.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/expressions.tex b/source/expressions.tex index 00e981f446..fd971051db 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -2635,7 +2635,7 @@ is of the form \tcode{->} \grammarterm{type-constraint}, then the contextually-determined type being constrained is \tcode{decltype((E))}. - The immediately-declared constraint\iref(temp) of \tcode{decltype((E))} + The immediately-declared constraint\iref{temp} of \tcode{decltype((E))} shall be satisfied. \begin{note} Thus, constraints of the form From 2fbf52f3b359af054ddb68fd121cff0910af37fa Mon Sep 17 00:00:00 2001 From: Casey Carter Date: Sat, 17 Nov 2018 12:57:17 -0800 Subject: [PATCH 6/6] [concepts] P1084R2 library wording changes --- 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}