Skip to content

Commit

Permalink
Guard RefCounted.opAssign(T)
Browse files Browse the repository at this point in the history
Needed for std.container.array now `move` target requires mutable T.
  • Loading branch information
ntrel committed Jul 27, 2024
1 parent dad7820 commit 344a1fc
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions std/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -10928,19 +10928,22 @@ struct RefCounted(T, RefCountedAutoInitialize autoInit =
swap(_refCounted._store, rhs._refCounted._store);
}

void opAssign(T rhs)
static if (__traits(compiles, lvalueOf!T = T.init))
{
import std.algorithm.mutation : move;

static if (autoInit == RefCountedAutoInitialize.yes)
{
_refCounted.ensureInitialized();
}
else
void opAssign(T rhs)
{
assert(_refCounted.isInitialized);
import std.algorithm.mutation : move;

static if (autoInit == RefCountedAutoInitialize.yes)
{
_refCounted.ensureInitialized();
}
else
{
assert(_refCounted.isInitialized);
}
move(rhs, _refCounted._store._payload);
}
move(rhs, _refCounted._store._payload);
}

static if (autoInit == RefCountedAutoInitialize.yes)
Expand Down

0 comments on commit 344a1fc

Please sign in to comment.