Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Is the constructor call a prvalue and what's the type of it? #4837

Copy link
Copy link
Closed
@xmh0511

Description

@xmh0511
Issue body actions

[intro.execution] p5

If a language construct is defined to produce an implicit call of a function, a use of the language construct is considered to be an expression for the purposes of this definition.

Hence, the implicit call of a constructor should be considered as an expression.

[class.ctor.general] p2

A constructor is used to initialize objects of its class type.

As well, some rules in the standard also imply a constructor call is used to initialize an object, such as

If overload resolution is successful, the selected constructor is called to initialize the object, with the initializer expression or expression-list as its argument(s).

Hence, the constructor call should be categorized to prvalue as per [basic.lval] p1

A prvalue is an expression whose evaluation initializes an object or computes the value of an operand of an operator, as specified by the context in which it appears, or an expression that has type cv void.

However, in the current standard, there is no common rule that phrases what's the type of a constructor call(i.e. what's the type of that prvalue). Furthermore, after the amending of #4737, this issue seems to become more obscure.

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.