Remix.run Logo
stonemetal12 3 days ago

This is like saying 1 + 2 isn't addition because the compiler will optimize it away. It isn't an addition instruction in the emitted code but logically speaking it is addition.

Similarly just because a compiler may optimize a prvalue away doesn't change the fact that a prvalue by definition of the language is a temp.

Sesse__ 3 days ago | parent [-]

The article specifically points out that this isn't about optimization. A temporary will not be created even with -O0 (you can observe this by putting logging into the copy and move constructors).

quuxplusone 3 days ago | parent [-]

Or even =delete'ing them or (carefully) putting static_asserts inside them. They're not called, not instantiated, not nothing.