diff options
| author | Nathan Sashihara <21227491+n8sh@users.noreply.github.com> | 2018-08-03 19:14:08 -0400 |
|---|---|---|
| committer | Nathan Sashihara <21227491+n8sh@users.noreply.github.com> | 2018-08-06 14:41:47 -0400 |
| commit | 22cffe9d6e094ed5a5ba4d4fb653f781efb73909 (patch) | |
| tree | 12a304681d2d0771e601c28caf4f42f0d96406c0 | |
| parent | b04928d2c85d7b1d1ea56246e2bd2bf7e652e52c (diff) | |
| download | tanya-22cffe9d6e094ed5a5ba4d4fb653f781efb73909.tar.gz | |
Set: allow hasher to take arg by ref
| -rw-r--r-- | source/tanya/container/set.d | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/tanya/container/set.d b/source/tanya/container/set.d index bd889a1..e5dc2d6 100644 --- a/source/tanya/container/set.d +++ b/source/tanya/container/set.d @@ -154,7 +154,7 @@ struct Range(T) * hasher = Hash function for $(D_PARAM T). */ struct Set(T, alias hasher = hash) -if (is(typeof(hasher(T.init)) == size_t)) +if (is(typeof(((T x) => hasher(x))(T.init)) == size_t)) { private alias HashArray = .HashArray!(hasher, T); private alias Buckets = HashArray.Buckets; @@ -767,3 +767,9 @@ if (is(typeof(hasher(T.init)) == size_t)) } testFunc(set); } + +@nogc nothrow pure @safe unittest +{ + // Using hasher that takes argument by ref. + Set!(int, (const ref x) => cast(size_t)x) set; +} |
