In the talk Non-conforming C++ from CppCon2019 it is introduced the "Elvis Operator" in C++, which is a non-standard extension supported by many compilers.
It works by omitting the middle operand of an ?: expression:
std::shared_ptr<foo> read();
std::shared_ptr<foo> default_value();
auto read_or_default()
{
return read() ?: default_value();
}
This is exactly the sample taken from slide 11 of the presentation.
However when I build it on GCC 7.4.0 on Ubuntu 18.04, or with GCC 8.2.0 on MinGW, using the -std=gnu++14 flag, I get this error:
error: lvalue required as unary '&' operand
return read() ?: default_value();
^
In the talk it is said that this extension is present in GCC at least since version 4.1.2.
So what's wrong?