Skip to content

CWG2713 [dcl.init.aggr], [over.ics.list] should allow list-initialization of a reference-to-aggregate from a designated initializer list #292

Closed
cplusplus/draft
#6328
@zygoloid

Description

@zygoloid

Reference (section label): [dcl.init.list], [over.ics.list]

Link to reflector thread (if any): https://lists.isocpp.org/ext/2023/04/21015.php

Issue description:

[dcl.init.list] says that a designated-initializer-list can only be used to initialize an aggregate class. [over.ics.list] says that a designated-initializer-list can only be used to form an implicit conversion sequence for an aggregate. Longstanding implementation practice and expectations of consistency suggest that we should additionally permit initialization of a (const or rvalue) reference to aggregate class, creating a temporary as normal.

Suggested resolution:

Change in [dcl.init.list]/3.1:

  • If the braced-init-list contains a designated-initializer-list and T is not a reference type, T shall be an aggregate class. [...]

Change in [over.ics.list]/2:

If the initializer list is a designated-initializer-list and the the parameter is not a reference, a conversion is only possible if the parameter has an aggregate type that can be initialized from the initializer list according to the rules for aggregate initialization ([dcl.init.aggr])

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