Which item stipulates that A() is a prvalue?
1 2 3 4 5
|
class A {
...
};
A();
|
This webpage lists all possible forms of prvalue expressions:
https://en.cppreference.com/w/cpp/language/value_category#prvalue. Which item stipulates that A() is a prvalue? I am guessing this item is plausible:
• a function call or an overloaded operator expression, whose return type is non-reference, such as ...
|
A() is a call to default constructor which is a (special) member function, and it does not return anything (so its return type is not a reference). But I am not sure, and the following examples do not contain expressions like A(). So I ask here for a confirmation. Thank you.
I suspect so, but cppreference.com is not the official specification so it's possible that its explanation is not 100% perfect.
If you instead look at the top of the page it says that
a prvalue is an expression whose evaluation initializes an object.
The same wording is also present in the standard itself:
https://eel.is/c++draft/basic.lval#1.2
The expression
A()
clearly initializes an object.
Last edited on
Topic archived. No new replies allowed.