Intelligent Scope Hierarchy
Stretto
uiy12345 at gmail.com
Thu Oct 31 22:49:02 PDT 2013
On Thursday, 31 October 2013 at 22:03:18 UTC, Namespace wrote:
> The 'it' property is only some 'singleton' approach.
> You can write:
>
> void foo() {
> auto buffer = Mallocator.allocate(42);
> /// ... many code
> }
>
> And at the end of the scope buffer is cleared because
> Mallocator's destructor call deallocateAll (if I'm not wrong).
That doesn't seem right? deallocateAll would deallocate all
allocated objects? Even outside of foo's scope? Also, how would
Mallocator.allocate know what to deallocate unless it kept a
history? Why would the example code explicitly deallocate the
object at the end of the scope if it were unnecessary?
More information about the Digitalmars-d-learn
mailing list