Can you please tell me if such code is correct (according to standard):
struct array {
int data[4];
operator const int*() const { return data; }
};
void function(const int*) { ... }
function(array()); // is array data valid inside function?
Thank you
Yes. The temporary object is valid until the end of the full expression in which it is created; that is, until after the function call returns.
I don’t have my copy of the standard to hand, so I can’t give the exact reference; but it’s in 12.2 of the C++0x final draft.