std.allocator ready for some abuse
Jacob Carlborg
doob at me.com
Fri Oct 25 05:52:13 PDT 2013
On 2013-10-25 02:01, Andrei Alexandrescu wrote:
> Oddly enough this can be actually done.
>
> with (setAllocator!Mallocator)
> {
> ...
> }
>
> setAllcator returns an rvalue that changes the global allocator to the
> Mallocator in the constructor, and restores it to whatever it was in the
> destructor.
Wouldn't this be very unsafe? Say you call another function inside the
with-statement and that function assumes the standard GC for allocating
memory.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list