I'm new to C++ and I'm reading this tutorial. I found the following code snippet.
X&& goo(); // (1)
X x = goo(); // (2)
I think X
is a class name, but I don't understand what X&& goo();
does. I suppose there are two possibilities:
- It declares a function
goo
which returns a rvalue reference to X. - It declares a variable
goo
and calls the default constructor (without arguments) of X.
But if 1 is true then since there is no function body how can it be called? And if 2 is true then what does line (2) do?
I tried to search for this syntax but wasn't able to figure out the correct keywords. Can anyone give a hint? Thanks!