3 ms·
For C++17, true. Not so if you're using an earlier compiler and/or language standard. Yes, yes, I know we should all get with the program, but that's alas not h
by PaulDavisThe1st 5y ago
For C++17, true. Not so if you're using an earlier compiler and/or language standard. Yes, yes, I know we should all get with the program, but that's alas not how the world operates.
- Kranar 5y agoThere is no std::optional in earlier language standards. std::optional is a C++17 library feature.
- PaulDavisThe1st 5y agoboost::optional has existed for many, many years and does not require compiler/language support. AFAIK, the behavior is substantially identical to std::optional.
- tsimionescu 5y agoEven for C++ 17, this is only guaranteed if you don't name the variable in your function. NRVO is not guaranteed at all. There is even an example downthread where gcc can't do it even at -O3.