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

2024-04-18


229. Partial specialization of function templates

Section: 13.7.6  [temp.spec.partial]     Status: NAD     Submitter: Dave Abrahams     Date: 1 Apr 2000

Library issue 225 poses the following questions:

  1. How can a 3rd party library implementor (lib1) write a version of a standard algorithm which is specialized to work with his own class template?
  2. How can another library implementor (lib2) write a generic algorithm which will take advantage of the specialized algorithm in lib1?

For example, a programmer might want to provide a version of std::swap that would be used for any specialization of a particular class template. It is possible to do that for specific types, but not for all specializations of a template.

The problem is due to the fact that programmers are forbidden to add overloads to namespace std, although specializations are permitted. One suggested solution would be to allow partial specialization of function templates, analogous to partial specialization of class templates.

Library issue 225 contains a detailed proposal for adding partial specialization of function templates (not reproduced here in the interest of space and avoiding multiple-copy problems). This Core issue is being opened to provide for discussion of the proposal within the core language working group.

Notes from 10/00 meeting:

A major concern over the idea of partial specialization of function templates is that function templates can be overloaded, unlike class templates. Simply naming the function template in the specialization, as is done for class specialization, is not adequate to identify the template being specialized.

In view of this problem, the library working group is exploring the other alternative, permitting overloads to be added to functions in namespace std, as long as certain restrictions (to be determined) are satisfied.

(See also documents N1295 and N1296 and issue 285.)

Notes from 10/01 meeting:

The Core Working Group decided to ask the Library Working Group for guidance on whether this feature is still needed to resolve a library issue. The answer at present is "we don't know."

Rationale (October, 2004):

The Core Working Group decided that the Evolution Working Group is the appropriate forum in which to explore the desirability and form of this feature.

Note (March, 2008):

The Evolution Working Group recommended closing this issue with no further consideration. See paper J16/07-0033 = WG21 N2173.