Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions utils/appender.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ private:
}

newStart[0..size] = start[0..size];
if (unique)
allocator.deallocate(start[0..capacity]);
static if (hasMember!(Allocator, "deallocate"))
if (unique)
allocator.deallocate(start[0..capacity]);
start = newStart;
cursor = start + size;
end = start + newCapacity;
Expand Down Expand Up @@ -117,8 +118,9 @@ public:

~this()
{
if (cursor && unique)
allocator.deallocate(start[0..end-start]);
static if (hasMember!(Allocator, "deallocate"))
if (cursor && unique)
allocator.deallocate(start[0..end-start]);
}

/// Put elements.
Expand Down Expand Up @@ -312,6 +314,21 @@ unittest
}
}

unittest
{
static struct MinimalAllocator
{
static MinimalAllocator instance;

void[] allocate(size_t size)
{
return new void[](size);
}
}

alias Test = FastAppender!(int, MinimalAllocator);
}

/// UFCS shim for classic output ranges, which only take a single-argument put.
void putEx(R, U...)(auto ref R r, U items)
{
Expand Down