Fix #247
Assigning RefCounted to RefCounted fails at compile time. https://issues.caraus.io/issues/247
This commit is contained in:
parent
7d5dda1cba
commit
ede0107fd7
@ -1,3 +1,4 @@
|
||||
ignore:
|
||||
- "source/tanya/async/event/iocp.d"
|
||||
- "source/tanya/async/iocp.d"
|
||||
- "source/tanya/memory/types.d"
|
||||
|
@ -63,6 +63,15 @@ package final class RefCountedStore(T)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private unittest
|
||||
{
|
||||
auto rcs = defaultAllocator.make!(RefCountedStore!int);
|
||||
assert(rcs >= 1);
|
||||
assert(rcs > 0);
|
||||
assert(!(rcs > 2));
|
||||
defaultAllocator.dispose(rcs);
|
||||
}
|
||||
}
|
||||
|
||||
package void separateDeleter(T)(RefCountedStore!T storage,
|
||||
@ -180,7 +189,7 @@ struct RefCounted(T)
|
||||
*
|
||||
* Returns: $(D_KEYWORD this).
|
||||
*/
|
||||
ref typeof(this) opAssign()(auto ref Payload!T rhs)
|
||||
ref typeof(this) opAssign(Payload!T rhs)
|
||||
{
|
||||
if (this.storage is null)
|
||||
{
|
||||
@ -198,18 +207,18 @@ struct RefCounted(T)
|
||||
finalize(this.storage.payload);
|
||||
this.storage.payload = Payload!T.init;
|
||||
}
|
||||
move(rhs, this.storage.payload);
|
||||
this.storage.payload = rhs;
|
||||
return this;
|
||||
}
|
||||
|
||||
private unittest
|
||||
private @nogc unittest
|
||||
{
|
||||
auto rc = defaultAllocator.refCounted!int(5);
|
||||
rc = defaultAllocator.make!int(7);
|
||||
assert(*rc == 7);
|
||||
}
|
||||
|
||||
private unittest
|
||||
private @nogc unittest
|
||||
{
|
||||
auto rc = defaultAllocator.refCounted!int(5);
|
||||
|
||||
@ -340,6 +349,12 @@ unittest
|
||||
assert(*rc.storage.payload == 9);
|
||||
}
|
||||
|
||||
private unittest
|
||||
{
|
||||
RefCounted!int rc1, rc2;
|
||||
static assert(is(typeof(rc1 = rc2)));
|
||||
}
|
||||
|
||||
version (unittest)
|
||||
{
|
||||
private class A
|
||||
@ -690,11 +705,10 @@ struct Unique(T)
|
||||
*
|
||||
* Returns: $(D_KEYWORD this).
|
||||
*/
|
||||
ref typeof(this) opAssign()(auto ref Payload!T rhs)
|
||||
ref typeof(this) opAssign(Payload!T rhs)
|
||||
{
|
||||
allocator.dispose(this.payload);
|
||||
move(rhs, this.payload);
|
||||
|
||||
this.payload = rhs;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -761,7 +775,7 @@ struct Unique(T)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets this $(D_PARAM Unique) to its initial state.
|
||||
* Sets the internal pointer to $(D_KEYWORD). The allocator isn't changed.
|
||||
*
|
||||
* Returns: Reference to the owned object.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user