Skip to content

Commit c7ada94

Browse files
committed
traits for opPostMove needed a different approach.
1 parent 07ead5e commit c7ada94

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

druntime/src/core/internal/moving.d

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ void __move_post_blt(S)(ref S newLocation, ref S oldLocation) nothrow
4040

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

4849
newLocation.opPostMove(oldLocation);

druntime/src/core/internal/traits.d

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,10 @@ template hasElaborateMove(S)
248248
}
249249
else static if (is(S == struct))
250250
{
251-
enum hasElaborateMove = (is(typeof(S.init.opPostMove(lvalueOf!S))) &&
252-
!is(typeof(S.init.opPostMove(rvalueOf!S)))) ||
251+
enum hasElaborateMove = (is(typeof(S.init.opPostMove)) &&
252+
Parameters!(S.init.opPostMove).length == 1 &&
253+
is(Parameters!(S.init.opPostMove)[0] : S) &&
254+
__traits(getParameterStorageClasses, S.init.opPostMove, 0)[0] == "ref") ||
253255
anySatisfy!(.hasElaborateMove, Fields!S);
254256
}
255257
else

0 commit comments

Comments
 (0)