diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-18 17:35:27 +0100 |
---|---|---|
committer | Iain Buclaw <ibuclaw@gdcproject.org> | 2025-01-18 23:42:43 +0100 |
commit | 2ead01297ced8fd03387021025222a839503eaf6 (patch) | |
tree | c3a12c13cf7d4b38d18eb51dd78aed4332beb786 /libphobos/src/std/algorithm | |
parent | 20a4306793e4978dfff13ca669739eb46915d4e4 (diff) | |
download | gcc-2ead01297ced8fd03387021025222a839503eaf6.zip gcc-2ead01297ced8fd03387021025222a839503eaf6.tar.gz gcc-2ead01297ced8fd03387021025222a839503eaf6.tar.bz2 |
d: Merge upstream dmd, druntime d115713410, phobos 1b242048c.
D front-end changes:
- Import latest fixes from dmd v2.110.0-rc.1.
- Integers in debug or version statements have been removed from
the language.
D runtime changes:
- Import latest fixes from druntime v2.110.0-rc.1.
Phobos changes:
- Import latest fixes from phobos v2.110.0-rc.1.
gcc/d/ChangeLog:
* dmd/MERGE: Merge upstream dmd d115713410.
libphobos/ChangeLog:
* libdruntime/MERGE: Merge upstream druntime d115713410.
* src/MERGE: Merge upstream phobos 1b242048c.
gcc/testsuite/ChangeLog:
* gdc.dg/asm3.d: Adjust test.
Diffstat (limited to 'libphobos/src/std/algorithm')
-rw-r--r-- | libphobos/src/std/algorithm/mutation.d | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libphobos/src/std/algorithm/mutation.d b/libphobos/src/std/algorithm/mutation.d index ea1a1b2..8a45ecb 100644 --- a/libphobos/src/std/algorithm/mutation.d +++ b/libphobos/src/std/algorithm/mutation.d @@ -2885,6 +2885,17 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs)))) { if (&lhs != &rhs) { + static if (__traits(compiles, lhs.tupleof = rhs.tupleof)) + { + if (__ctfe) + { + // can't reinterpret cast + foreach (i, ref e; lhs.tupleof) + swap(e, rhs.tupleof[i]); + return; + } + } + // For structs with non-trivial assignment, move memory directly ubyte[T.sizeof] t = void; auto a = (cast(ubyte*) &lhs)[0 .. T.sizeof]; @@ -3128,6 +3139,18 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs)))) swap(a3, a4); } +// https://issues.dlang.org/show_bug.cgi?id=21429 +@safe unittest +{ + enum e = (){ + Tuple!int a = 5, b = 6; + swap(a, b); + assert(a[0] == 6); + assert(b[0] == 5); + return 0; + }(); +} + /** Swaps two elements in-place of a range `r`, specified by their indices `i1` and `i2`. |