Skip to content

Commit

Permalink
Change to deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Jul 27, 2024
1 parent 344a1fc commit b43ae94
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,14 @@ Params:
copy is performed.
*/
void move(T)(ref T source, ref T target)
if (__traits(compiles, target = T.init))
{
moveImpl(target, source);
}

deprecated("Can't move into `target` as `T` can't be assigned")
void move(T)(ref T source, ref T target)
if (!__traits(compiles, target = T.init))
{
moveImpl(target, source);
}
Expand Down Expand Up @@ -1191,7 +1199,10 @@ unittest
immutable int i;
~this() @safe {}
}
static assert(!__traits(compiles, { S a, b; move(a, b); }));
alias os = __traits(getOverloads, std.algorithm.mutation, "move", true);
static assert(__traits(isDeprecated, os[1]));
// uncomment after deprecation
//static assert(!__traits(compiles, { S a, b; move(a, b); }));
}

/// Ditto
Expand Down Expand Up @@ -1253,7 +1264,6 @@ pure nothrow @safe @nogc unittest
}

private void moveImpl(T)(ref scope T target, ref return scope T source)
if (__traits(compiles, target = T.init))
{
import std.traits : hasElaborateDestructor;

Expand Down

0 comments on commit b43ae94

Please sign in to comment.