Is not the reference valid for the lifetime of the temporary object? I was certain pg.245 of N3337 implies that the temporary object the reference was bound to will exist for the duration of the function, in particular 12.2.5. Am I reading this wrong?
It's kind of a weird part of C++. The reference/object exists, and it will exist for the duration of the function, but it might not really exist... Confusing? A little. There are two types of existance. The "readonly" type of existence, and the "read+write" type of existence. The object exists (in terms of being able to read it) as far as 12.2.5 is concerned. "existence" doesn't mean you can write to an object. It just means it's there.
I suggest reading this. One of the big reasons for this whole thing is to avoid bugs where temporaries are accidentally modified. (think of it, being able to do 2 = 1; would be weird...)
I also suggest reading this. It might not seem like it makes a lot of sense, and in some ways, it doesn't, but it's just one of those things in C++.
Edited by Cornstalks, 04 April 2013 - 05:03 PM.