co-locate overloads of std.algorithm.mutation.swap() (#8951)

This commit is contained in:
Walter Bright 2024-10-17 22:18:04 -07:00 committed by GitHub
parent 1ea91e6674
commit a51c0eada6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2860,6 +2860,13 @@ Params:
lhs = Data to be swapped with `rhs`.
rhs = Data to be swapped with `lhs`.
*/
void swap(T)(ref T lhs, ref T rhs)
if (is(typeof(lhs.proxySwap(rhs))))
{
lhs.proxySwap(rhs);
}
/// ditto
void swap(T)(ref T lhs, ref T rhs) @trusted pure nothrow @nogc
if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
{
@ -3121,13 +3128,6 @@ if (isBlitAssignable!T && !is(typeof(lhs.proxySwap(rhs))))
swap(a3, a4);
}
/// ditto
void swap(T)(ref T lhs, ref T rhs)
if (is(typeof(lhs.proxySwap(rhs))))
{
lhs.proxySwap(rhs);
}
/**
Swaps two elements in-place of a range `r`,
specified by their indices `i1` and `i2`.