Skip to content

Commit 87f577e

Browse files
authored
Merge 2019-07 CWG Motion 18
P1452R2 On the non-uniform semantics of return-type-requirements Fixes #2998.
2 parents 84a5ebb + 258be1c commit 87f577e

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

source/expressions.tex

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@
25052505
template<typename T>
25062506
concept R = requires (T i) {
25072507
typename T::type;
2508-
{*i} -> const typename T::type&;
2508+
{*i} -> ConvertibleTo<const typename T::type&>;
25092509
};
25102510
\end{codeblock}
25112511
A \grammarterm{requires-expression} can also be used in a
@@ -2645,7 +2645,6 @@
26452645

26462646
\begin{bnf}
26472647
\nontermdef{return-type-requirement}\br
2648-
trailing-return-type\br
26492648
\terminal{->} type-constraint
26502649
\end{bnf}
26512650

@@ -2673,19 +2672,8 @@
26732672
into the \grammarterm{return-type-requirement} is performed.
26742673

26752674
\item
2676-
If the \grammarterm{return-type-requirement} is a
2677-
\grammarterm{trailing-return-type}\iref{dcl.decl},
2678-
%%% FIXME: is -> shall be
2679-
\tcode{E} is implicitly convertible to
2680-
the type named by the \grammarterm{trailing-return-type}.
2681-
If conversion fails, the enclosing \grammarterm{requires-expression}
2682-
is \tcode{false}.
2683-
2684-
\item
2685-
If the \grammarterm{return-type-requirement}
2686-
is of the form \tcode{->} \grammarterm{type-constraint}, then
2687-
the contextually-determined type being constrained
2688-
is \tcode{decltype((E))}.
2675+
The contextually-determined type being constrained
2676+
by the \grammarterm{type-constraint} is \tcode{decltype((E))}.
26892677
The immediately-declared constraint\iref{temp} of \tcode{decltype((E))}
26902678
shall be satisfied.
26912679
\begin{example}
@@ -2722,15 +2710,14 @@
27222710

27232711
\begin{codeblock}
27242712
template<typename T> concept C2 = requires(T x) {
2725-
{*x} -> typename T::inner;
2713+
{*x} -> Same<typename T::inner>;
27262714
};
27272715
\end{codeblock}
27282716

27292717
The \grammarterm{compound-requirement} in \tcode{C2}
27302718
requires that \tcode{*x} is a valid expression,
27312719
that \tcode{typename T::inner} is a valid type, and
2732-
that \tcode{*x} is implicitly convertible to
2733-
\tcode{typename T::inner}.
2720+
that \tcode{Same<decltype((*x)), typename T::inner>} is satisfied.
27342721

27352722
\begin{codeblock}
27362723
template<typename T> concept C3 =

source/iterators.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,15 +880,15 @@
880880
is_lvalue_reference_v<iter_reference_t<I>> &&
881881
Same<remove_cvref_t<iter_reference_t<I>>, typename readable_traits<I>::value_type> &&
882882
requires(I i) {
883-
{ i++ } -> const I&;
883+
{ i++ } -> ConvertibleTo<const I&>;
884884
{ *i++ } -> Same<iter_reference_t<I>>;
885885
};
886886

887887
template<class I>
888888
concept @\placeholder{cpp17-bidirectional-iterator}@ =
889889
@\placeholder{cpp17-forward-iterator}@<I> && requires(I i) {
890890
{ --i } -> Same<I&>;
891-
{ i-- } -> const I&;
891+
{ i-- } -> ConvertibleTo<const I&>;
892892
{ *i-- } -> Same<iter_reference_t<I>>;
893893
};
894894

@@ -902,7 +902,7 @@
902902
{ n + i } -> Same<I>;
903903
{ i - n } -> Same<I>;
904904
{ i - i } -> Same<decltype(n)>;
905-
{ i[n] } -> iter_reference_t<I>;
905+
{ i[n] } -> ConvertibleTo<iter_reference_t<I>>;
906906
};
907907
\end{codeblock}
908908

source/ranges.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,8 @@
11251125
requires DerivedFrom<tuple_size<T>, integral_constant<size_t, 2>>;
11261126
typename tuple_element_t<0, remove_const_t<T>>;
11271127
typename tuple_element_t<1, remove_const_t<T>>;
1128-
{ get<0>(t) } -> const tuple_element_t<0, T>&;
1129-
{ get<1>(t) } -> const tuple_element_t<1, T>&;
1128+
{ get<0>(t) } -> ConvertibleTo<const tuple_element_t<0, T>&>;
1129+
{ get<1>(t) } -> ConvertibleTo<const tuple_element_t<1, T>&>;
11301130
};
11311131

11321132
template<class T, class U, class V>

source/templates.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3924,7 +3924,7 @@
39243924
\begin{codeblock}
39253925
template<typename T>
39263926
concept C = requires(T x) {
3927-
{ x == x } -> bool;
3927+
{ x == x } -> ConvertibleTo<bool>;
39283928
};
39293929

39303930
template<typename T>

0 commit comments

Comments
 (0)