Consider this code:
struct foo
{
int a;
};
foo q() { foo f; f.a =4; return f;}
int main()
{
foo i;
i.a = 5;
q() = i;
}
No compile
One interesting application of this:
void f(const std::string& x);
std::string g() { return ""; }
...
f(g() += " ");
Here, g() +=
modifies the temporary, which may be faster that creating an additional temporary with +
because the heap allocated for g()'s return value may already have enough spare capacity to accommodate .
See it run at ideone.com with GCC / C++11.
Now, which computing novice said something about optimisations and evil...? ;-].