This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1509. Definition of “non-template function”

Section: Clause 3  [intro.defs]     Status: C++14     Submitter: Johannes Schaub     Date: 2012-06-08

[Moved to DR at the September, 2013 meeting.]

The term “non-template function” is used in various places but never defined.

Proposed resolution (June, 2013):

  1. Change 7.6.1.3 [expr.call] paragraph 1 as follows:

  2. There are two kinds of function call: ordinary function call and member function [Footnote: A static member function (11.4.9 [class.static]) is an ordinary function. —end foot note] (11.4.2 [class.mfct]) call. A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses which constitute the arguments to the function. The postfix expression shall have function type or pointer to function type. For an ordinary function a call to a non-member function or to a static member function, the postfix expression shall be either... For a member function call to a non-static member function, the postfix expression shall be...
  3. Add a new paragraph before 9.3.4.6 [dcl.fct] paragraph 13:

  4. A non-template function is a function that is not a function template specialization. [Note: A function template is not a function. —end note]

    A declarator-id or abstract-declarator containing an ellipsis shall only be used...

  5. Change the footnote in 12.2.2 [over.match.funcs] paragraph 7 as follows:

  6. The process of argument deduction fully determines the parameter types of the function template specializations, i.e., the parameters of function template specializations contain no template parameter types. Therefore the, except where specified otherwise, function template specializations can be treated as normal (non-template) functions and non-template functions (9.3.4.6 [dcl.fct]) are treated equivalently for the remainder of overload resolution.
  7. Change the final sub-bullet of 12.2.2.3 [over.match.oper] paragraph 3 as follows:

  8. For a unary operator @...

  9. Change the indicated bullet of the second bulleted list of 12.2.4 [over.match.best] paragraph 1 as follows:

  10. Change 12.3 [over.over] paragraph 4 as follows:

  11. If more than one function is selected, any function template specializations in the set are eliminated if the set also contains a non-template function that is not a function template specialization, and any given function template specialization F1 is eliminated
  12. Change Clause 13 [temp] paragraph 5 as follows:

  13. A class template shall not have the same name as any other template, class, function, variable, enumeration, enumerator, namespace, or type in the same scope (6.4 [basic.scope]), except as specified in (13.7.6 [temp.spec.partial]). Except that a function template can be overloaded either by (non-template) functions (9.3.4.6 [dcl.fct]) with the same name or by other function templates with the same name (13.10.4 [temp.over]), a template name declared in namespace scope or in class scope shall be unique in that scope.
  14. Change 13.7.3 [temp.mem] paragraph 2 as follows:

  15. A local class of non-closure type shall not have member templates. Access control rules (11.8 [class.access]) apply to member template names. A destructor shall not be a member template. A normal (non-template) member function (9.3.4.6 [dcl.fct]) with a given name and type and a member function template of the same name, which could be used to generate a specialization of the same type, can both be declared in a class. When both exist, a use of that name and type refers to the non-template member unless an explicit template argument list is supplied. [Example:

      template <class T> struct A {
        void f(int);
        template <class T2> void f(T2);
      };
    
      template <> void A<int>::f(int) { }               // non-template member function
      template <> template <> void A<int>::f<>(int) { } // template member function template specialization
    
      int main() {
        A<char> ac;
        ac.f(1);       // non-template
        ac.f('c');     // template
        ac.f<>(1);     // template
      }
    

    end example]

  16. Change 13.7.5 [temp.friend] paragraph 1 as follows:

  17. A friend of a class or class template can be a function template or class template, a specialization of a function template or class template, or an ordinary ( a non-template) function or class. For a friend function declaration that is not a template declaration:

  18. Change 13.7.5 [temp.friend] paragraph 4 as follows:

  19. When a function is defined in a friend function declaration in a class template, the function is instantiated when the function is odr-used (6.3 [basic.def.odr]). The same restrictions...
  20. Change 13.7.7 [temp.fct] paragraph 2 as follows:

  21. A function template can be overloaded with other function templates and with normal (non-template) functions (9.3.4.6 [dcl.fct]). A normal non-template function is not related to a function template (i.e., it is never considered to be a specialization), even if it has the same name and type as a potentially generated function template specialization.144
  22. Change 13.10.2 [temp.arg.explicit] paragraph 4 as follows:

  23. [Note: An empty template argument list can be used to indicate that a given use refers to a specialization of a function template even when a normal (i.e., non-template) function (9.3.4.6 [dcl.fct]) is visible that would otherwise be used. For example:...