> Also try: > > foreach(uint i;0..10000) { > scope Foo f = new Foo(i); > // Do something with f ... > } > > That sometimes doesn't require allocations.
To be sure I understand -- is there anything wrong with writing scope auto f = new Foo(i) ... or, in general, using auto to infer the class being initiated? I found myself disliking the double writing of Foo, although I guess there could be a positive side to it in ensuring that the class really is what it's meant to be.