auto allocator = TestAllocator(); { const foo = Unique!(Struct, TestAllocator*)(&allocator, 5); foo.twice.shouldEqual(10); allocator.numAllocations.shouldEqual(1); Struct.numStructs.shouldEqual(1); } Struct.numStructs.shouldEqual(0);
import std.experimental.allocator.mallocator: Mallocator; { const foo = Unique!(Struct, Mallocator)(5); foo.twice.shouldEqual(10); Struct.numStructs.shouldEqual(1); } Struct.numStructs.shouldEqual(0);