From b43ae94d64a55e954d70a76a054449fa1e05296d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Sat, 27 Jul 2024 21:20:41 +0100 Subject: [PATCH] Change to deprecation --- std/algorithm/mutation.d | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/std/algorithm/mutation.d b/std/algorithm/mutation.d index c550ef1a8aa..9d31056a9b8 100644 --- a/std/algorithm/mutation.d +++ b/std/algorithm/mutation.d @@ -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); } @@ -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 @@ -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;