Skip to content

Commit

Permalink
Fix compilation on DMD 2.065.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Feb 21, 2015
1 parent ba47eb9 commit 32bf475
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions source/vibe/utils/hashmap.d
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,15 @@ unittest {
}
}

// test for @nogc compliance
unittest {
// test for nothrow/@nogc compliance
static if (__VERSION__ >= 2066)
nothrow unittest {
HashMap!(int, int) map1;
HashMap!(string, string) map2;
map1[1] = 2;
map2["1"] = "2";

@nogc void performNoGCOps()
@nogc nothrow void performNoGCOps()
{
foreach (int v; map1) {}
foreach (int k, int v; map1) {}
Expand All @@ -291,32 +292,12 @@ unittest {
performNoGCOps();
}

// test nothrow compliance
nothrow unittest {
HashMap!(int, int) map1;
HashMap!(string, string) map2;
map1[1] = 2;
map2["1"] = "2";

foreach (int v; map1) {}
foreach (int k, int v; map1) {}
assert(1 in map1);
assert(map1.length == 1);
assert(map1[1] == 2);
assert(map1.getNothrow(1, -1) == 2);

foreach (string v; map2) {}
foreach (string k, string v; map2) {}
assert("1" in map2);
assert(map2.length == 1);
assert(map2["1"] == "2");
assert(map2.getNothrow("1", "") == "2");
}

private template UnConst(T) {
static if (is(T U == const(U))) {
alias UnConst = U;
} else static if (is(T V == immutable(V))) {
alias UnConst = V;
} else alias UnConst = T;
}

static if (__VERSION__ < 2066) private static bool nogc() { return false; }

0 comments on commit 32bf475

Please sign in to comment.