3 ms·
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
by stonemetal12 1y 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__ 1y agoThe 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 1y agoOr even =delete'ing them or (carefully) putting static_asserts inside them. They're not called, not instantiated, not nothing.