0

From cppreference

Temporary objects are created .. in the following situations:

  • conversion that creates a prvalue (including T(a,b,c) and T{})

When this can happen? (examples will be appreciated)

What does they mean by "including T(a,b,c) and T{}"?

Do static_cast<T>(e), const_cast<T>(e), dynamic_cast<T>(e) and reinterpret_cast<T>(e) conversions are always evaluate to prvalue?

  • 1
    the notion of what a converting constructor is has changed in C++11 https://en.cppreference.com/w/cpp/language/converting_constructor – 463035818_is_not_an_ai Feb 16 '22 at 07:36
  • 1
    Both "conversion" and "including" on that page are links leading to other pages. For a full picture, along with more examples, visit the first 6 pages linked under "conversion" and locate each conversion type that returns a pre-C++17 prvalue. – Cubbi Feb 16 '22 at 22:18

1 Answers1

1

When this can happen? (examples will be appreciated)

What does they mean by "including T(a,b,c) and T{}"?

"including T(a,b,c) and T{}" means that T(a,b,c) and T{} are examples of cases where temporary objects are created (until C++17).

Do static_cast<T>(e), const_cast<T>(e), dynamic_cast<T>(e) and reinterpret_cast<T>(e) conversions are always evaluate to prvalue?

No. The quoted sentence implies that there are prvalue conversions and non-prvalue conversions, and the latter don't necessarily create temporary objects. If T is a reference type, then the conversion is a glvalue.

eerorika
  • 232,697
  • 12
  • 197
  • 326