Skip to content

Commit e4f579e

Browse files
jensmaurerzygoloid
authored andcommitted
[temp.arg.nontype] Fix example involving string literal
P0732R2 contained some changes to this section that were missing explicit markup; apply those changes too. Also fix missing definition of operator<=> in class type used as type of non-type template parameter.
1 parent e95b0bf commit e4f579e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

source/templates.tex

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,18 +1368,21 @@
13681368
\begin{example}
13691369

13701370
\begin{codeblock}
1371-
template<class T, const char* p> class X {
1371+
template<class T, T p> class X {
13721372
@\commentellip@
13731373
};
13741374

1375-
X<int, "Studebaker"> x1; // error: string literal as template-argument
1375+
X<const char*, "Studebaker"> x; // error: string literal as template-argument
13761376

13771377
const char p[] = "Vivisectionist";
1378-
X<int,p> x2; // OK
1378+
X<const char*, p> y; // OK
13791379

1380-
class A { constexpr A(const char*) {} };
1380+
class A {
1381+
constexpr A(const char*) {}
1382+
auto operator<=>(A, A) = default;
1383+
};
13811384

1382-
X<A, "Pyrophoricity"> x3; // OK, string literal is a constructor argument to A
1385+
X<A, "Pyrophoricity"> z; // OK, string literal is a constructor argument to \tcode{A}
13831386
\end{codeblock}
13841387
\end{example}
13851388
\end{note}

0 commit comments

Comments
 (0)