Title
Restrictions on non-type template arguments in partial specializations
Status
cd4
Section
_N4868_.13.7.6 [temp.class.spec]
Submitter
Johannes Schaub

Created on 2011-05-12.00:00:00 last changed 57 months ago

Messages

Date: 2015-09-15.00:00:00

Proposed resolution (September, 2015):

Change _N4868_.13.7.6 [temp.class.spec] bullet 8.1 as follows:

  • A partially specialized non-type argument expression shall not involve a template parameter of the partial specialization except when the argument expression is a simple identifier. Each template-parameter shall appear at least once in the template-id outside a non-deduced context. [Example:

  •   template <int I, int J> struct A {};
      template <int I> struct A<I+5, I*2> {};   // error
    
      template <int I, int J> struct B {};
      template <int I> struct B A<I, I> {};     // OK
    
      template <int I, int J, int K> struct B {};
      template <int I> struct B<I, I*2, 2> {};  // OK
    

    end example]

Date: 2016-02-15.00:00:00

[Adopted at the February, 2016 meeting.]

The rationale for the restriction in _N4868_.13.7.6 [temp.class.spec] paragraph 8, first bullet is not clear:

  • A partially specialized non-type argument expression shall not involve a template parameter of the partial specialization except when the argument expression is a simple identifier. [Example:

  •   template <int I, int J> struct A {};
      template <int I> struct A<I+5, I*2> {}; // error
      template <int I, int J> struct B {};
      template <int I> struct B<I, I> {};     // OK
    

    end example]

In the example, it's clear that I is non-deducible, but this rule prevents plausible uses like:

  template <int I, int J> struct A {};
  template <int I> struct A<I, I*2> {};

(See also issues 1647, 2033, and 2127.)

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: tentatively ready -> cd4
2015-11-10 00:00:00adminsetmessages: + msg5609
2015-11-10 00:00:00adminsetstatus: drafting -> tentatively ready
2011-05-12 00:00:00admincreate