Title
Unclear restrictions on use of function-type template arguments
Status
cd4
Section
13.4.2 [temp.arg.type]
Submitter
David Krauss

Created on 2015-03-17.00:00:00 last changed 49 months ago

Messages

Date: 2015-09-15.00:00:00

Proposed resolution (September, 2015):

  1. Delete 13.4.2 [temp.arg.type] paragraph 3:

  2. If a declaration acquires a function type through a type dependent on a template-parameter and this causes a declaration that does not use the syntactic form of a function declarator to have function type, the program is ill-formed. [Example:

      template<class T> struct A {
        static T t;
      };
      typedef int function();
      A<function> a; // ill-formed: would declare A<function>::t
                     // as a static member function
    

    end example]

  3. Add the following as a new paragraph following 13.9 [temp.spec] paragraph 6:
  4. ...X<int> has a static member s of type int and X<char*> has a static member s of type char*. —end example]

    If a function declaration acquired its function type through a dependent type (13.8.3.2 [temp.dep.type]) without using the syntactic form of a function declaator, the program is ill-formed. [Example:

       template<class T> struct A {
         static T t;
       };
       typedef int function();
       A<function> a;   // ill-formed: would declare A<function>::t
                        // as a static member function
    

    end example]

Date: 2016-02-15.00:00:00

[Adopted at the February, 2016 meeting.]

According to 13.4.2 [temp.arg.type] paragraph 3,

If a declaration acquires a function type through a type dependent on a template-parameter and this causes a declaration that does not use the syntactic form of a function declarator to have function type, the program is ill-formed.

This is not clear enough regarding which declarations are in view. For example, does it apply to a typedef declaration? Does it apply to a parameter declaration, where normal function-to-pointer decay would apply? There is implementation variance at block scope.

Also, since this applies a restriction to the usage of dependent types, not template type arguments per se, the paragraph presumably should appear in 13.8.3.2 [temp.dep.type] and not its current location.

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: tentatively ready -> cd4
2015-11-10 00:00:00adminsetmessages: + msg5608
2015-11-10 00:00:00adminsetstatus: drafting -> tentatively ready
2015-03-17 00:00:00admincreate