Thinking about (x|r|l|pr|gl)values, the following question came to my mind:
Consider the following two variable declarations:
X x = ...;
and
X&& x = ...;
and assume the ...
do not deliver an xvalue.
Can anybody think of code not using decltype
in which this makes a difference? In both cases, (x)
will by an lvalue of type X
, won't it?
Maybe artificial example, but with
struct X
{
X() = default;
X(const X&) = delete;
X operator =(const X&) = delete;
X(X&&) = delete;
X operator =(X&&) = delete;
};
X makeX() {return {};}
following compiles
X&& x = makeX();
whereas following doesn't
X x = makeX();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With