This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3513. Fix definition of program-defined based on its uses

Section: 3.43 [defns.prog.def.type] Status: New Submitter: Johel Ernesto Guerrero Peña Opened: 2020-12-29 Last modified: 2021-01-30

Priority: 3

View all issues with New status.

Discussion:

Consider the following definitions:

3.42 [defns.prog.def.spec]
program-defined specialization
<library> explicit template specialization or partial specialization that is not part of the C++ standard library and not defined by the implementation

and

3.43 [defns.prog.def.type]
program-defined type
<library> non-closure class type or enumeration type that is not part of the C++ standard library and not defined by the implementation, or a closure type of a non-implementation-provided lambda expression, or an instantiation of a program-defined specialization [Note 1 to entry: Types defined by the implementation include extensions (4.1) and internal types used by the library. — end note]

A program-defined type is either a type or an instantiation. "program-defined type" is used in 16.4.5.2.1 [namespace.std] p2 to give permission to specialize standard class templates:

Unless explicitly prohibited, a program may add a template specialization for any standard library class template to namespace std provided that (a) the added declaration depends on at least one program-defined type and (b) the specialization meets the standard library requirements for the original template.

ISO requires that the terms in Clause 3 be substitutable with their definitions. If this were done for "program-defined type", we'd end up with "or an instantiation of a program-defined specialization". It's fine to depend on a type, but not an instantiated type, because all you need is the name of its specialization (its type) as a template argument to explicitly or partially specialize a template.

[2021-01-29; reflector prioritization]

Set priority to 3 following reflector discussions. It was pointed out that it might be easier to resolve 3512 if this issue changes the definition of program-defined type.

Proposed resolution:

This wording is relative to N4878.

  1. Modify 3.43 [defns.prog.def.type] as indicated:

    3.43 [defns.prog.def.type]
    program-defined type
    <library> non-closure class type or enumeration type that is not part of the C++ standard library and not defined by the implementation, or a closure type of a non-implementation-provided lambda expression, or an instantiationa name of a program-defined specialization or instantiation thereof [Note 1 to entry: Types defined by the implementation include extensions (4.1 [intro.compliance]) and internal types used by the library. — end note]