Title
Restriction on non-type, non-value template arguments
Status
tc1
Section
13.2 [temp.param]
Submitter
Mike Miller

Created on 1998-10-16.00:00:00 last changed 262 months ago

Messages

Date: 1999-04-15.00:00:00

Proposed Resolution (04/99): Change the example in 13.2 [temp.param] paragraph 8 from:

    template<int *a> struct R { /* ... */ };
    template<int b[5]> struct S { /* ... */ };
    int *p;
    R<p> w; // OK
    S<p> x; // OK due to parameter adjustment
    int v[5];
    R<v> y; // OK due to implicit argument conversion
    S<v> z; // OK due to both adjustment and conversion
to:
    template<int *a> struct R { /* ... */ };
    template<int b[5]> struct S { /* ... */ };
    int p;
    R<&p> w; // OK
    S<&p> x; // OK due to parameter adjustment
    int v[5];
    R<v> y; // OK due to implicit argument conversion
    S<v> z; // OK due to both adjustment and conversion
Furthermore, in 13.4.3 [temp.arg.nontype] paragraph 1:
  • the fourth bullet item should be changed from "...where the & is optional if the name refers to a function or array;" to "...where the & is optional if the name refers to a function or array, or if the corresponding template-parameter is a reference;"
  • the third bullet item should be removed.
Date: 2022-11-20.07:54:16

The example in 13.2 [temp.param] paragraph 8 is:

    template<int* a> struct R { /*...*/ };
    int* p;
    R<p> w;
There was a French comment was that this is an error, and there was general agreement with that.

I've been looking for the verbiage that specifies that this is an error and haven't found it. In particular, nothing in 13.2 [temp.param] ("Template parameters") nor 13.4.3 [temp.arg.nontype] ("Template non-type arguments") appears to rule out this case. (13.4.3 [temp.arg.nontype] paragraph 1 allows an argument to be "the name of an object or function with external linkage," with no limitation on the kinds of parameters such a name can match; "p" is, in fact, such a name.)

Should the resolution of the French comment include beefing up one or both of these sections to cover the applicable rules explicitly?

Proposed Resolution (04/99): Change the example in 13.2 [temp.param] paragraph 8 from:

    template<int *a> struct R { /* ... */ };
    template<int b[5]> struct S { /* ... */ };
    int *p;
    R<p> w; // OK
    S<p> x; // OK due to parameter adjustment
    int v[5];
    R<v> y; // OK due to implicit argument conversion
    S<v> z; // OK due to both adjustment and conversion
to:
    template<int *a> struct R { /* ... */ };
    template<int b[5]> struct S { /* ... */ };
    int p;
    R<&p> w; // OK
    S<&p> x; // OK due to parameter adjustment
    int v[5];
    R<v> y; // OK due to implicit argument conversion
    S<v> z; // OK due to both adjustment and conversion
Furthermore, in 13.4.3 [temp.arg.nontype] paragraph 1:
  • the fourth bullet item should be changed from "...where the & is optional if the name refers to a function or array;" to "...where the & is optional if the name refers to a function or array, or if the corresponding template-parameter is a reference;"
  • the third bullet item should be removed.
History
Date User Action Args
2003-04-25 00:00:00adminsetstatus: dr -> tc1
1999-09-14 00:00:00adminsetmessages: + msg209
1999-09-14 00:00:00adminsetstatus: drafting -> dr
1998-10-16 00:00:00admincreate