Title
Nontype template arguments in constant expressions
Status
cd1
Section
7.7 [expr.const]
Submitter
Mark Mitchell

Created on 2005-08-21.00:00:00 last changed 161 months ago

Messages

Date: 2007-04-15.00:00:00

[Voted into the WP at the April, 2007 meeting as part of paper J16/07-0095 = WG21 N2235.]

Date: 2008-05-15.00:00:00

Additional note (May, 2008):

This issue is resolved by the rewrite of 7.7 [expr.const] that was done in conjunction with the constexpr proposal, paper N2235.

Date: 2006-04-15.00:00:00

Notes from April, 2006 meeting:

The proposed resolution could potentially be read as saying that the prohibited operations and operators would be permitted in integral constant expressions that are non-type template-arguments. John Spicer is investigating an alternate approach, to say that expressions in non-type template arguments are not part of the expression in which the template-id appears (in contrast to the operand of sizeof, which is part of the containing expression).

Date: 2005-10-15.00:00:00

Proposed resolution (October, 2005):

Change the last sentence of 7.7 [expr.const] paragraph 1 as indicated:

In particular, except in non-type template-arguments or sizeof expressions, functions, class objects, pointers, or references shall not be used, and assignment, increment, decrement, function-call, or comma operators shall not be used.

(Note: the same text is changed by the resolution of issue 367.)

Date: 2005-08-21.00:00:00

Consider:

    template <int* p> struct S {
        static const int I = 3;
    };
    int i;
    int a[S<&i>::I];

Clearly this should be valid, but a pedantic reading of 7.7 [expr.const] would suggest that this is invalid because “&i” is not permitted in integral constant expressions.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2008-05-18 00:00:00adminsetmessages: + msg1673
2008-05-18 00:00:00adminsetmessages: + msg1672
2008-05-18 00:00:00adminsetstatus: drafting -> wp
2006-04-22 00:00:00adminsetmessages: + msg1330
2006-04-22 00:00:00adminsetstatus: ready -> drafting
2005-10-22 00:00:00adminsetmessages: + msg1219
2005-08-21 00:00:00admincreate