diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-05 14:56:59 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-10 22:09:00 +0100 |
commit | 89629b271827357f81f6f8c7cf28f59919519864 (patch) | |
tree | bc6ae2e8d764a128cd9501b30ad96ce7e6360e85 /libphobos/src/std/algorithm | |
parent | c9353e0fcd0ddc0d48ae8a2b0518f0f82670d708 (diff) | |
download | gcc-89629b271827357f81f6f8c7cf28f59919519864.zip gcc-89629b271827357f81f6f8c7cf28f59919519864.tar.gz gcc-89629b271827357f81f6f8c7cf28f59919519864.tar.bz2 |
d: Merge dmd, druntime 34875cd6e1, phobos ebd24da8a
D front-end changes:
- Import dmd v2.110.0-beta.1.
- `ref' can now be applied to local, static, extern, and global
variables.
D runtime changes:
- Import druntime v2.110.0-beta.1.
Phobos changes:
- Import phobos v2.110.0-beta.1.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd 34875cd6e1.
* dmd/VERSION: Bump version to v2.110.0-beta.1.
* Make-lang.in (D_FRONTEND_OBJS): Add d/deps.o, d/timetrace.o.
* decl.cc (class DeclVisitor): Update for new front-end interface.
* expr.cc (class ExprVisitor): Likewise
* typeinfo.cc (check_typeinfo_type): Likewise.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime 34875cd6e1.
* src/MERGE: Merge upstream phobos ebd24da8a.
Diffstat (limited to 'libphobos/src/std/algorithm')
-rw-r--r-- | libphobos/src/std/algorithm/mutation.d | 23 | ||||
-rw-r--r-- | libphobos/src/std/algorithm/sorting.d | 6 |
2 files changed, 26 insertions, 3 deletions
diff --git a/libphobos/src/std/algorithm/mutation.d b/libphobos/src/std/algorithm/mutation.d index fbef28e..e434d24 100644 --- a/libphobos/src/std/algorithm/mutation.d +++ b/libphobos/src/std/algorithm/mutation.d @@ -1071,10 +1071,20 @@ Params: copy is performed. */ void move(T)(ref T source, ref T target) +if (__traits(compiles, target = T.init)) { moveImpl(target, source); } +/// ditto +template move(T) +if (!__traits(compiles, imported!"std.traits".lvalueOf!T = T.init)) +{ + /// + deprecated("Can't move into `target` as `" ~ T.stringof ~ "` can't be assigned") + void move(ref T source, ref T target) => moveImpl(target, source); +} + /// For non-struct types, `move` just performs `target = source`: @safe unittest { @@ -1184,6 +1194,19 @@ pure nothrow @safe @nogc unittest assert(s53 is s51); } +@system unittest +{ + static struct S + { + immutable int i; + ~this() @safe {} + } + alias ol = __traits(getOverloads, std.algorithm.mutation, "move", true)[1]; + static assert(__traits(isDeprecated, ol!S)); + // uncomment after deprecation + //static assert(!__traits(compiles, { S a, b; move(a, b); })); +} + /// Ditto T move(T)(return scope ref T source) { diff --git a/libphobos/src/std/algorithm/sorting.d b/libphobos/src/std/algorithm/sorting.d index c5b085d..2d16c65 100644 --- a/libphobos/src/std/algorithm/sorting.d +++ b/libphobos/src/std/algorithm/sorting.d @@ -2164,12 +2164,12 @@ private void quickSortImpl(alias less, Range)(Range r, size_t depth) { import std.algorithm.comparison : min, max; import std.algorithm.mutation : swap, swapAt; - import std.conv : to; alias Elem = ElementType!(Range); - enum size_t shortSortGetsBetter = max(32, 1024 / Elem.sizeof); + enum int size = Elem.sizeof; + enum size_t shortSortGetsBetter = max(32, 1024 / size); static assert(shortSortGetsBetter >= 1, Elem.stringof ~ " " - ~ to!string(Elem.sizeof)); + ~ size.stringof); // partition while (r.length > shortSortGetsBetter) |