I've come across a situation where being able to chain a method call to a temporary variable would be really helpful:
draw(Quad(0, 0, 1, 1).rotate(90)); // <-- .rotate() returns a Quad reference
struct Quad{
Quad(float x, float y, float width, float height){...}
Quad & rotate(float degrees){
...
return *this;
}
}
However, I'm unsure if the temporary variable will remain alive long enough for the draw()
function to use it. Is this safe to do?