Skip to content

Commit

Permalink
traits for opPostMove needed a different approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurkeyMan committed Nov 17, 2024
1 parent 044da06 commit feabd4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions druntime/src/core/internal/moving.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ void __move_post_blt(S)(ref S newLocation, ref S oldLocation) nothrow

static if (__traits(hasMember, S, "opPostMove"))
{
import core.internal.traits : lvalueOf, rvalueOf;
static assert( is(typeof(S.init.opPostMove(lvalueOf!S))) &&
!is(typeof(S.init.opPostMove(rvalueOf!S))),
import core.internal.traits : Parameters;
static assert(Parameters!(S.init.opPostMove).length == 1 &&
is(Parameters!(S.init.opPostMove)[0] : const S) &&
__traits(getParameterStorageClasses, S.init.opPostMove, 0)[0] == "ref",
"`" ~ S.stringof ~ ".opPostMove` must take exactly one argument of type `" ~ S.stringof ~ "` by reference");

newLocation.opPostMove(oldLocation);
Expand Down
6 changes: 4 additions & 2 deletions druntime/src/core/internal/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ template hasElaborateMove(S)
}
else static if (is(S == struct))
{
enum hasElaborateMove = (is(typeof(S.init.opPostMove(lvalueOf!S))) &&
!is(typeof(S.init.opPostMove(rvalueOf!S)))) ||
enum hasElaborateMove = (is(typeof(S.init.opPostMove)) &&
Parameters!(S.init.opPostMove).length == 1 &&
is(Parameters!(S.init.opPostMove)[0] : const S) &&
__traits(getParameterStorageClasses, S.init.opPostMove, 0)[0] == "ref") ||
anySatisfy!(.hasElaborateMove, Fields!S);
}
else
Expand Down

0 comments on commit feabd4d

Please sign in to comment.