Skip to content

Commit b238a71

Browse files
tkoeppezygoloid
authored andcommitted
CWG2322 Substitution failure and lexical order
1 parent 0773d07 commit b238a71

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/templates.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7173,6 +7173,9 @@
71737173
inside \tcode{sizeof}, \tcode{decltype}, and other contexts that allow non-constant
71747174
expressions. The substitution proceeds in lexical order and stops when
71757175
a condition that causes deduction to fail is encountered.
7176+
If substitution into different declarations of the same function template would
7177+
cause template instantiations to occur in a different order or not at all,
7178+
the program is ill-formed; no diagnostic required.
71767179
\begin{note}
71777180
The equivalent substitution in exception specifications is
71787181
done only when the \grammarterm{noexcept-specifier} is instantiated,
@@ -7186,10 +7189,14 @@
71867189
template <class T> void f(...) { }
71877190
template <class T> auto g(typename A<T>::X) -> typename T::X;
71887191
template <class T> void g(...) { }
7192+
template <class T> typename T::X h(typename A<T>::X);
7193+
template <class T> auto h(typename A<T>::X) -> typename T::X; // redeclaration
7194+
template <class T> void h(...) { }
71897195

7190-
void h() {
7196+
void x() {
71917197
f<int>(0); // OK, substituting return type causes deduction to fail
71927198
g<int>(0); // error, substituting parameter type instantiates \tcode{A<int>}
7199+
h<int>(0); // ill-formed, no diagnostic required
71937200
}
71947201
\end{codeblock}
71957202
\end{example}

0 commit comments

Comments
 (0)