On Monday, December 24, 2012 21:42:09 monarch_dodra wrote: > Side question, is this legal? > > "int a = min(min(1,2), min(3,4));" > > How long do those temps last? I like this piece of code, because > the previous had that fishy "const int&", which raises eyebrows, > but I think this example could blindsind even the most careful > programmer. > > EDIT: In this specific example, those might be statics, so the > code would be legal, but what if we replace those ints with > "foo()"s ?
As I understand it, temporaries last for the duration of the statement that they're used it. So, the example would be legal and completely safe. - Jonathan M Davis
