diff --git a/source/tanya/container/list.d b/source/tanya/container/list.d index adbd4fd..d0946d9 100644 --- a/source/tanya/container/list.d +++ b/source/tanya/container/list.d @@ -215,16 +215,19 @@ struct SList(T) * If $(D_PARAM init) is passed by reference, it will be copied. * * Params: + * R = Source list type. * init = Source list. * allocator = Allocator. */ - this(ref SList init, shared Allocator allocator = defaultAllocator) + this(R)(ref R init, shared Allocator allocator = defaultAllocator) + if (is(Unqual!R == SList)) { this(init[], allocator); } /// Ditto. - this(SList init, shared Allocator allocator = defaultAllocator) @trusted + this(R)(R init, shared Allocator allocator = defaultAllocator) @trusted + if (is(R == SList)) { this(allocator); if (allocator is init.allocator) @@ -734,18 +737,19 @@ struct SList(T) * * Returns: $(D_KEYWORD this). */ - ref typeof(this) opAssign(R)(const ref R that) + ref typeof(this) opAssign(R)(ref R that) if (is(Unqual!R == SList)) { return this = that[]; } /// Ditto. - ref typeof(this) opAssign(R)(const ref R that) - if (is(Unqual!R == SList)) + ref typeof(this) opAssign(R)(R that) + if (is(R == SList)) { swap(this.head, that.head); swap(this.allocator_, that.allocator_); + return this; } /** diff --git a/source/tanya/container/vector.d b/source/tanya/container/vector.d index 7f56bf0..1e9360a 100644 --- a/source/tanya/container/vector.d +++ b/source/tanya/container/vector.d @@ -225,11 +225,11 @@ struct Vector(T) * If $(D_PARAM init) is passed by reference, it will be copied. * * Params: - * R = Vector type. + * R = Source vector type. * init = Source vector. * allocator = Allocator. */ - this(R)(const ref R init, shared Allocator allocator = defaultAllocator) + this(R)(ref R init, shared Allocator allocator = defaultAllocator) if (is(Unqual!R == Vector)) { this(allocator); @@ -1413,7 +1413,7 @@ struct Vector(T) * * Returns: $(D_KEYWORD this). */ - ref typeof(this) opAssign(R)(const ref R that) + ref typeof(this) opAssign(R)(ref R that) if (is(Unqual!R == Vector)) { return this = that[]; diff --git a/source/tanya/math/mp.d b/source/tanya/math/mp.d index e8dcce3..e55829c 100644 --- a/source/tanya/math/mp.d +++ b/source/tanya/math/mp.d @@ -245,16 +245,10 @@ struct Integer ref Integer opAssign(T)(T value) nothrow @safe @nogc if (is(T == Integer)) { - if (this.allocator is value.allocator) - { - swap(this.rep, value.rep); - swap(this.sign, value.sign); - swap(this.size, value.size); - } - else - { - this = value; - } + swap(this.rep, value.rep); + swap(this.sign, value.sign); + swap(this.size, value.size); + swap(this.allocator_, value.allocator_); return this; }