From e27d0fe58cae50e9f592a8db6b5052a19f3bcba3 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 4 Jan 2017 20:37:55 +0100 Subject: Fix Vector.remove not destroying from the end copied elements --- source/tanya/container/vector.d | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/tanya/container/vector.d b/source/tanya/container/vector.d index 0992733..e582714 100644 --- a/source/tanya/container/vector.d +++ b/source/tanya/container/vector.d @@ -650,6 +650,8 @@ struct Vector(T) * r = Range originally obtained from this vector. * * Returns: Elements in $(D_PARAM r) after removing. + * + * Precondition: $(D_PARAM r) refers to a region of $(D_KEYWORD this). */ Range!T remove(Range!T r) @trusted in @@ -663,7 +665,7 @@ struct Vector(T) { *a = *b; } - length_ -= r.length; + length = length_ - r.length; return r; } @@ -790,7 +792,7 @@ struct Vector(T) ref T opIndexAssign(ref T value, in size_t pos) @trusted in { - assert(length > pos); + assert(length_ > pos); } body { -- cgit v1.2.3