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

2024-03-20


1577. Unnecessary restrictions on partial specializations

Section: 13.7.6.1  [temp.spec.partial.general]     Status: NAD     Submitter: Jeremiah Wilcox     Date: 2012-10-19

One of the restrictions on partial specializations found in 13.7.6.1 [temp.spec.partial.general] paragraph 9 is:

The template parameter list of a specialization shall not contain default template argument values. [Footnote: There is no way in which they could be used. —end footnote]

The rationale for this restriction is incorrect, since default template argument values can be used to trigger SFINAE and thus control whether a particular partial specialization is used. An example of this use is:

    template <typename T> struct a;
    template <typename T,
         typename = typename std::enable_if<some property>::type>
    struct a<std::vector<T>> { ... };

which is forbidden by this point. Note also that an example like

    template <typename T> struct b;
    template <typename T,
         typename = typename std::enable_if<some property>::type>
    struct b<T> { ... };

is likely forbidden by the previous bullet:

The argument list of the specialization shall not be identical to the implicit argument list of the primary template.

This restriction may also need to be weakened.

Rationale (April, 2013)

CWG felt that consideration of these suggestions was more appropriately done by EWG.

Additional note, April, 2015:

EWG has decided not to make a change in this area. See EWG issue 110.