is safe code (it works in DEBUG):
void takesPointer(const Type* v);
Type getValue();
...
takesPointer(&getValue());
...
Type tmp = getValue();
takesPointer(&tmp);
so - is it safe? should i just forget about it and use code with explicit tmp?
but anyway - I still wonder if the optimizer is allowed to kill the temporary before returning from this call:
takePointer(&getValue())
EDIT: Thank you all! unfortunately, I cannot change the "takePointer" function (this is part of the library), I could only wrap it in the "takeReference" function, which calls takePointer - this will eliminate the copy, or the compiler is still allowed to create a copy ("Type" - it is an int-3x3-Matrix, so that would not be so, but still ...)?
inline void takesReference(const Type& v){ takesPointer(&v); }
On the time of destruction: will it be destroyed after the "takePointer" RETURNS or after its call?