Skip to content

CWG2714 [over.match.class.deduct] implicit deduction guide wording does not inherit important properties from the parameter-declaration-clause of a constructor #290

Closed
cplusplus/draft
#6906
@zygoloid

Description

@zygoloid

Reference (section label): [over.match.class.deduct]

Link to reflector thread (if any): https://lists.isocpp.org/core/2017/02/1752.php

Issue description:

[over.match.class.deduct]/1.1.2 says:

The types of the function parameters are those of the constructor.

... but does not say that default arguments are inherited, and likewise does not say that the deduction guide is variadic if the constructor is variadic.

Similar issues arise with constraints on the constructor.

Suggested resolution:

Change in [over.match.class.deduct]/1:

[...]

  • If C is defined, for each constructor of C, a function template with the following properties:
    - The template parameters are the template parameters of C followed by the template parameters (including default template arguments) of the constructor, if any.
    - The associated constraints are the associated constraints of C followed by the associated constraints of the constructor, if any. [Note: A constraint-expression in the template-head of C is checked for satisfaction before any constraints from the template-head or trailing-requires-clause of the constructor.]
    - The types of the function parameters are those parameter-declaration-clause is that of the constructor.
  • [...]
  • For each deduction-guide, a function or function template with the following properties:
    - The explicit-specifier and template parameters template-head, if any, and function parameters parameter-declaration-clause are those of the deduction-guide.
    - The return type is the simple-template-id of the deduction-guide.

Aside: should deduction-guides allow a trailing requires-clause? (GCC and MSVC allow this; Clang and the grammar do not.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions