cpp_weekly
cpp_weekly copied to clipboard
RVO and trivial types
It's not possible to observe this, but we can see the resulting code and measure it, so let's do that.
https://quick-bench.com/q/T_oEovXBmsW5MJGvJa5sIJn3WVI
Note that clang applies RVO in both branches, in all cases. This is a missed "optimization" by GCC. But declaring them both at the top of the function would break clang too, because it cannot apply RVO to both (right? I should try that)
https://quick-bench.com/q/dQ2JY98sZlklSUYX6HamT8gVxH4
https://compiler-explorer.com/z/dr1TdhM1M
Coming in 456