Why should not the rule for class member access with an xvalue object expression [expr]/7.3 apply to reference types?
Together with [expr.ref]/4
"If E2 is declared to have type “reference to T”, then E1.E2 is an lvalue; the type of E1.E2 is T."
information on expiration is changed without obvious reason.
Anybody knows the reason for this decision?
#include <utility>
int i;
struct { int && m; } a { std::move (i) };
typedef decltype ((std::move (a).m)) M;
// M is int &, not &&
static_assert ((std::is_same <M, int &>::value), "");
int main () {}
I guess why I'm bothered in the first place is that it's breaking the trivial solution to forwarding class members:
template <typename U> auto f (U && u)
-> decltype ((static_cast <U &&> (u).m))
{
return static_cast <U &&> (u).m;
}
without any apparent alternatives, except resorting to more complicated type traits solutions.