Title
Clarify why string literals are not allowed as template arguments
Status
tc1
Section
13.4.3 [temp.arg.nontype]
Submitter
Mike Miller

Created on 1999-03-09.00:00:00 last changed 263 months ago

Messages

Date: 1999-10-15.00:00:00

Proposed Resolution (10/99): In 13.4.3 [temp.arg.nontype] paragraph 2, change

[Note: a string literal (5.13.5 [lex.string] ) is not an acceptable template-argument because a string literal is an object with internal linkage.
to
[Note: a string literal (5.13.5 [lex.string] ) does not satisfy the requirements of any of these categories and thus is not an acceptable template-argument.
Date: 2022-11-20.07:54:16

The explanation in 13.4.3 [temp.arg.nontype] paragraph 2 of why a string literal cannot be used as a template argument leaves something to be desired:

...because a string literal is an object with internal linkage.
I can't find anything that says that a string literal has internal linkage. In fact, I'd be pretty surprised if I did, since linkage is defined (in 6.6 [basic.link] ) strictly in terms of names, and a string literal doesn't have a name. Actually, I think that it's the namelessness of a string literal that prevents it from being a template argument; only the third and fourth bullets of 13.4.3 [temp.arg.nontype] paragraph 1 could conceivably apply, and both of those require that the entity have a name (i.e., that they be given as an id-expression).

Proposed Resolution (10/99): In 13.4.3 [temp.arg.nontype] paragraph 2, change

[Note: a string literal (5.13.5 [lex.string] ) is not an acceptable template-argument because a string literal is an object with internal linkage.
to
[Note: a string literal (5.13.5 [lex.string] ) does not satisfy the requirements of any of these categories and thus is not an acceptable template-argument.
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
2000-02-23 00:00:00adminsetstatus: ready -> dr
1999-09-14 00:00:00adminsetmessages: + msg87
1999-03-09 00:00:00admincreate