Function Subspace :: sus :: ptr :: swap_nonoverlapping
template <class T>
auto swap_nonoverlapping(UnsafeFnMarker, T* x, T* y, sus::usize count) -> void
requires
sus::mem::Move<T>
!std::is_const_v<T>
Swaps the object array at x with the object array at y, where both
arrays have a length of count.
If T is trivially relocatable (sus::mem::TriviallyRelocatable<T> is true),
then the swap may be done by memcpy() or equivalent to be more efficient.
Safety
To avoid Undefined Behaviour, the following must be met:
- The pointers
xandymust both be non-null and properly aligned forT. - The memory region at
xand includingcountelements must not overlap the region atyincludingcountelements. - The objects at
xandymust not have an overlapping object in their tail padding. Ifxandyare arrays, or were heap allocated, then this will always be satisfied.