c++constructorprvalue

Constructor call is a prvalue expression


In the C++ standard one can find examples of prvalue expressions:

"prvalue

The following expressions are prvalue expressions:

a literal (except for string literal), such as 42, true or nullptr;

a function call or an overloaded operator expression of non-reference return type, such as str.substr(1, 2), str1 + str2, or it++; ..."

Is this where an expression such as T() (a constructor call) would go?

Is there another name for such expressions?


Solution

  • Although the particular case of a default constructor puzzles me a bit, this is considered a cast expression, which is a bit lower on the list:

    • a cast expression to non-reference type, such as static_cast<double>(x), std::string{}, or (int)42;

    Even though the idea of converting nothing is peculiar, the T() syntax is indeed covered as form #4 here.