Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[concepts] P1084R2 library wording changes #2488

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions source/concepts.tex
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@
is_lvalue_reference_v<LHS> &&
CommonReference<const remove_reference_t<LHS>&, const remove_reference_t<RHS>&> &&
requires(LHS lhs, RHS&& rhs) {
lhs = std::forward<RHS>(rhs);
requires Same<decltype(lhs = std::forward<RHS>(rhs)), LHS>;
{ lhs = std::forward<RHS>(rhs) } -> Same<LHS>;
};
\end{itemdecl}

Expand Down Expand Up @@ -757,19 +756,19 @@
requires(const remove_reference_t<B>& b1,
const remove_reference_t<B>& b2, const bool a) {
requires ConvertibleTo<const remove_reference_t<B>&, bool>;
!b1; requires ConvertibleTo<decltype(!b1), bool>;
b1 && a; requires Same<decltype(b1 && a), bool>;
b1 || a; requires Same<decltype(b1 || a), bool>;
b1 && b2; requires Same<decltype(b1 && b2), bool>;
a && b2; requires Same<decltype( a && b2), bool>;
b1 || b2; requires Same<decltype(b1 || b2), bool>;
a || b2; requires Same<decltype( a || b2), bool>;
b1 == b2; requires ConvertibleTo<decltype(b1 == b2), bool>;
b1 == a; requires ConvertibleTo<decltype(b1 == a), bool>;
a == b2; requires ConvertibleTo<decltype( a == b2), bool>;
b1 != b2; requires ConvertibleTo<decltype(b1 != b2), bool>;
b1 != a; requires ConvertibleTo<decltype(b1 != a), bool>;
a != b2; requires ConvertibleTo<decltype( a != b2), bool>;
{ !b1 } -> ConvertibleTo<bool>;
{ b1 && a } -> Same<bool>;
{ b1 || a } -> Same<bool>;
{ b1 && b2 } -> Same<bool>;
{ a && b2 } -> Same<bool>;
{ b1 || b2 } -> Same<bool>;
{ a || b2 } -> Same<bool>;
{ b1 == b2 } -> ConvertibleTo<bool>;
{ b1 == a } -> ConvertibleTo<bool>;
{ a == b2 } -> ConvertibleTo<bool>;
{ b1 != b2 } -> ConvertibleTo<bool>;
{ b1 != a } -> ConvertibleTo<bool>;
{ a != b2 } -> ConvertibleTo<bool>;
};
\end{itemdecl}

Expand Down Expand Up @@ -811,10 +810,10 @@
concept @\placeholder{weakly-equality-comparable-with}@ = // \expos
requires(const remove_reference_t<T>& t,
const remove_reference_t<U>& u) {
t == u; requires Boolean<decltype(t == u)>;
t != u; requires Boolean<decltype(t != u)>;
u == t; requires Boolean<decltype(u == t)>;
u != t; requires Boolean<decltype(u != t)>;
{ t == u } -> Boolean;
{ t != u } -> Boolean;
{ u == t } -> Boolean;
{ u != t } -> Boolean;
};
\end{itemdecl}

Expand Down Expand Up @@ -888,10 +887,10 @@
EqualityComparable<T> &&
requires(const remove_reference_t<T>& a,
const remove_reference_t<T>& b) {
a < b; requires Boolean<decltype(a < b)>;
a > b; requires Boolean<decltype(a > b)>;
a <= b; requires Boolean<decltype(a <= b)>;
a >= b; requires Boolean<decltype(a >= b)>;
{ a < b } -> Boolean;
{ a > b } -> Boolean;
{ a <= b } -> Boolean;
{ a >= b } -> Boolean;
};
\end{itemdecl}

Expand Down Expand Up @@ -925,14 +924,14 @@
EqualityComparableWith<T, U> &&
requires(const remove_reference_t<T>& t,
const remove_reference_t<U>& u) {
t < u; requires Boolean<decltype(t < u)>;
t > u; requires Boolean<decltype(t > u)>;
t <= u; requires Boolean<decltype(t <= u)>;
t >= u; requires Boolean<decltype(t >= u)>;
u < t; requires Boolean<decltype(u < t)>;
u > t; requires Boolean<decltype(u > t)>;
u <= t; requires Boolean<decltype(u <= t)>;
u >= t; requires Boolean<decltype(u >= 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}

Expand Down
101 changes: 40 additions & 61 deletions source/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
\terminal{->} type-constraint
\end{bnf}

\pnum
Expand All @@ -2610,45 +2610,43 @@
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 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
\tcode{\{ E \} -> Concept<>;} are equivalent to
\tcode{E; requires Concept<decltype((E))>;}
while a constraint of the form
\tcode{\{ E \} -> Concept<A$_1$, A$_2$, . . . , A$_n$>;} is equivalent to
\tcode{E; requires Concept<decltype((E)), A$_1$, A$_2$, ..., A$_n$>;}.
\end{note}
\end{itemize}
\end{itemize}

\begin{example}
Expand All @@ -2675,32 +2673,13 @@
\tcode{typename T::inner}.

\begin{codeblock}
template<typename T, typename U> concept C3 = requires (T t, U u) {
t == u;
};
template<typename T> concept C4 = requires(T x) {
{*x} -> C3<int> const&;
};
\end{codeblock}
The \grammarterm{compound-requirement}
requires that \tcode{*x} be deduced
as an argument for the invented function:
\begin{codeblock}
template<C3<int> 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<typename T> concept C5 =
template<typename T> 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}
Expand Down