Re:Const all the things?
by Kranar on Monday January 24, 2022 @01:57PM
(#30062210)
There is no std::optional in earlier language standards. std::optional is a C++17 library feature.
[ Parent
| on HN ]
Re:Const all the things?
by tsimionescu on Monday January 24, 2022 @02:46PM
(#30062922)
Even 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.
Re:Const all the things?
by PaulDavisThe1st on Monday January 24, 2022 @02:04PM
(#30062298)
boost::optional has existed for many, many years and does not require compiler/language support. AFAIK, the behavior is substantially identical to std::optional.