Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #536 from quickfur/issue6646
Browse files Browse the repository at this point in the history
Fix issue 6646: array.reserve should be callable from SafeD.
  • Loading branch information
alexrp committed Jul 2, 2013
2 parents 8d2d60f + 4004da2 commit fa85c1b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/object.di
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ private
return _d_arraysetcapacity(typeid(T[]), 0, cast(void *)&arr);
}

size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow
size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow @trusted
{
return _d_arraysetcapacity(typeid(T[]), newcapacity, cast(void *)&arr);
}
Expand Down
9 changes: 8 additions & 1 deletion src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,7 @@ unittest
* The return value is the new capacity of the array (which may be larger than
* the requested capacity).
*/
size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow
size_t reserve(T)(ref T[] arr, size_t newcapacity) pure nothrow @trusted
{
return _d_arraysetcapacity(typeid(T[]), newcapacity, cast(void *)&arr);
}
Expand All @@ -2583,6 +2583,13 @@ unittest
assert(u == a.capacity); //a should not have been extended
}

// Issue 6646: should be possible to use array.reserve from SafeD.
@safe unittest
{
int[] a;
a.reserve(10);
}

/**
* Assume that it is safe to append to this array. Appends made to this array
* after calling this function may append in place, even if the array was a
Expand Down

0 comments on commit fa85c1b

Please sign in to comment.