Pass allocator in all HashTable/Set constructors

This commit is contained in:
Eugen Wissner 2019-04-14 07:41:26 +02:00
parent e6c6a2d21a
commit 9814e5ad8e
6 changed files with 37 additions and 32 deletions

View File

@ -7,12 +7,12 @@ os:
language: d
d:
- dmd-2.085.0
- dmd-2.085.1
- dmd-2.081.2
env:
global:
- LATEST=2.085.0
- LATEST=2.085.1
matrix:
- ARCH=x86_64

View File

@ -174,7 +174,7 @@ parameter is used)
| DMD | GCC |
|:-----------------:|:---------------:|
| 2.081.2 — 2.085.0 | gdc-8 (2.081.2) |
| 2.081.2 — 2.085.1 | gdc-8 (2.081.2) |
| | gdc-7 (2.081.2) |
### Release management

View File

@ -4,10 +4,10 @@ os: Visual Studio 2015
environment:
matrix:
- DC: dmd
DVersion: 2.085.0
DVersion: 2.085.1
arch: x64
- DC: dmd
DVersion: 2.085.0
DVersion: 2.085.1
arch: x86
- DC: dmd
DVersion: 2.081.2

View File

@ -416,8 +416,8 @@ if (isHashFunction!(hasher, Key))
*
* Precondition: $(D_INLINECODE allocator !is null).
*/
this(R)(R range, shared Allocator allocator = defaultAllocator)
if (isForwardRange!R && is(ElementType!R == KeyValue))
this(R)(scope R range, shared Allocator allocator = defaultAllocator)
if (isForwardRange!R && is(ElementType!R == KeyValue) && !isInfinite!R)
in (allocator !is null)
{
this(allocator);
@ -450,6 +450,7 @@ if (isHashFunction!(hasher, Key))
shared Allocator allocator = defaultAllocator)
in (allocator !is null)
{
this(allocator);
insert(array[]);
}
@ -714,8 +715,8 @@ if (isHashFunction!(hasher, Key))
*
* Returns: The number of the inserted elements with a unique key.
*/
size_t insert(R)(R range)
if (isForwardRange!R && is(ElementType!R == KeyValue))
size_t insert(R)(scope R range)
if (isForwardRange!R && is(ElementType!R == KeyValue) && !isInfinite!R)
{
size_t count;
foreach (e; range)

View File

@ -39,7 +39,7 @@ struct SRange(L)
invariant (this.head !is null);
private this(ref EntryPointer head) @trusted
private this(return ref EntryPointer head) @trusted
{
this.head = &head;
}
@ -127,7 +127,7 @@ struct SList(T)
* init = Values to initialize the list with.
* allocator = Allocator.
*/
this(R)(R init, shared Allocator allocator = defaultAllocator)
this(R)(scope R init, shared Allocator allocator = defaultAllocator)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -372,7 +372,7 @@ struct SList(T)
}
/// ditto
size_t insertFront(R)(R el) @trusted
size_t insertFront(R)(scope R el) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -473,7 +473,7 @@ struct SList(T)
}
/// ditto
size_t insertBefore(R)(Range r, R el)
size_t insertBefore(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -798,7 +798,7 @@ struct SList(T)
*
* Returns: $(D_KEYWORD this).
*/
ref typeof(this) opAssign(R)(R that) @trusted
ref typeof(this) opAssign(R)(scope R that) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -893,7 +893,8 @@ struct DRange(L)
invariant (this.head !is null);
invariant (this.tail !is null);
private this(ref EntryPointer head, ref EntryPointer tail) @trusted
private this(return ref EntryPointer head, return ref EntryPointer tail)
@trusted
{
this.head = &head;
this.tail = &tail;
@ -1010,7 +1011,7 @@ struct DList(T)
* init = Values to initialize the list with.
* allocator = Allocator.
*/
this(R)(R init, shared Allocator allocator = defaultAllocator)
this(R)(scope R init, shared Allocator allocator = defaultAllocator)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -1261,13 +1262,10 @@ struct DList(T)
// Creates a lsit of linked entries from a range.
// Returns count of the elements in the list.
private size_t makeList(R)(ref R el, out Entry* head, out Entry* tail) @trusted
out (retLength)
{
assert((retLength == 0 && head is null && tail is null)
|| (retLength > 0 && head !is null && tail !is null));
}
do
private size_t makeList(R)(scope ref R el, out Entry* head, out Entry* tail)
@trusted
out (retLength; (retLength == 0 && head is null && tail is null)
|| (retLength > 0 && head !is null && tail !is null))
{
size_t retLength;
@ -1335,7 +1333,7 @@ struct DList(T)
}
/// ditto
size_t insertFront(R)(R el)
size_t insertFront(R)(scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -1454,7 +1452,7 @@ struct DList(T)
}
/// ditto
size_t insertBack(R)(R el) @trusted
size_t insertBack(R)(scope R el) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -1581,7 +1579,7 @@ struct DList(T)
}
/// ditto
size_t insertBefore(R)(Range r, R el)
size_t insertBefore(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -1686,7 +1684,7 @@ struct DList(T)
}
/// ditto
size_t insertAfter(R)(Range r, R el)
size_t insertAfter(R)(Range r, scope R el)
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))
@ -2067,7 +2065,7 @@ struct DList(T)
*
* Returns: $(D_KEYWORD this).
*/
ref typeof(this) opAssign(R)(R that) @trusted
ref typeof(this) opAssign(R)(scope R that) @trusted
if (!isInfinite!R
&& isInputRange!R
&& isImplicitlyConvertible!(ElementType!R, T))

View File

@ -218,10 +218,13 @@ if (isHashFunction!(hasher, T))
*
* Precondition: $(D_INLINECODE allocator !is null).
*/
this(R)(R range, shared Allocator allocator = defaultAllocator)
if (isForwardRange!R && isImplicitlyConvertible!(ElementType!R, T))
this(R)(scope R range, shared Allocator allocator = defaultAllocator)
if (isForwardRange!R
&& isImplicitlyConvertible!(ElementType!R, T)
&& !isInfinite!R)
in (allocator !is null)
{
this(allocator);
insert(range);
}
@ -248,6 +251,7 @@ if (isHashFunction!(hasher, T))
this(size_t n)(T[n] array, shared Allocator allocator = defaultAllocator)
in (allocator !is null)
{
this(allocator);
insert(array[]);
}
@ -456,8 +460,10 @@ if (isHashFunction!(hasher, T))
*
* Returns: The number of new elements inserted.
*/
size_t insert(R)(R range)
if (isForwardRange!R && isImplicitlyConvertible!(ElementType!R, T))
size_t insert(R)(scope R range)
if (isForwardRange!R
&& isImplicitlyConvertible!(ElementType!R, T)
&& !isInfinite!R)
{
size_t count;
foreach (e; range)