It is kind of annoying if the compiler can't correctly optimize away "temporaries" though. In my compiler I didn't even leave that kind of logic until the optimization stage and instead added it in as a basic part of compilation.
6:44 Why would you ever need to rely on NRVO, other than for efficiency? The only situation I can think of is if you’re trying to return a non-copyable, non-movable object from a function. But in that case, the compiler could not return the object and you’d get an error diagnostic, with or without a -Wnrvo compiler option.
Why would you ever need a job, other than for money? The only situation I can think of is if you're a psychopath that needs to blend in society without being noticed.
If you actually don't want elision, you can disable the warning by wrapping the return value in std::move (when the returned type has a suitable constructor). The intent may not be obvious to the reader, though...
Woudn't be cool to have [[rvo]] attribute for functions? It could report error if compiler is not able to do it.
I have had a lot of discussions about this exact idea lately. I want one for tail calls as well
Cool to have more control over rvo warnings, but absolutely horrible as more stuff to put in function declaration
this would've been useful to me like a week before. Had to pull one of your older videos about std::optional\std::variant and RVO to get it 'right'
C++ under the sea being in the Netherlands made me laugh...
On brand marketing
Netherlands going under the sea in 20 years?!
It's even funnier that, phonetically, C sounds like "sea", so it's sea++, which is not exactly what you want if you're already under the sea
@@ohwow2074 It's already below sea level today. That's the joke
I also love the name of the online conference Pure Virtual C++.
Awesome!
"MSVC compilers down" ... who cares?
I care
They're back now, either way
@@MattGodbolt Thank you for the amazing tool!
@@keris3920 You're welcome, honestly the main thing I do these days is admin and devops; I have a team of volunteers who do all the actual work :)
maybe C++ is getting simpler after all!
is this included in -Wall or -Wpedantic ?
Nope
Can you mix RVO and NRVO?
It is kind of annoying if the compiler can't correctly optimize away "temporaries" though. In my compiler I didn't even leave that kind of logic until the optimization stage and instead added it in as a basic part of compilation.
Great addition, tho I feel like as attribute it wouldn't get in the way as much as when it is global warning.
This is super neat Great video Jason!
6:44 Why would you ever need to rely on NRVO, other than for efficiency? The only situation I can think of is if you’re trying to return a non-copyable, non-movable object from a function. But in that case, the compiler could not return the object and you’d get an error diagnostic, with or without a -Wnrvo compiler option.
exactly as you said, for efficiency
Why would you ever need a job, other than for money? The only situation I can think of is if you're a psychopath that needs to blend in society without being noticed.
Thank you 👍👍
If you actually don't want elision, you can disable the warning by wrapping the return value in std::move (when the returned type has a suitable constructor). The intent may not be obvious to the reader, though...
I still prefer MinGW and Clang over MSVC for a reason...
How this is relevant to the video? He is using GCC :)
@@TrueWodzuMinGW is a GCC port for Windows
@@literallynull thanks!
Feels like C++ getting worse and worse. Now it's not ok to move objects out of a functions Yay :(
It has never been okay to move objects out of functions.
C++ is not getting worse, but quite the opposite.