Why is it not allowed to get non-const reference to a temporary object, which function getx() returns? Clearly, this is prohibited by C++ Standard but I am in
getx()
Why would you ever want X& x = getx();? Just use X x = getx(); and rely on RVO.
X& x = getx();
X x = getx();