Function Subspace :: sus :: ptr :: copy_nonoverlapping
!std::is_const_v<T>
Copies count * size_of<T>()
bytes from src
to dst
. The source and
destination must not overlap.
For regions of memory which might overlap, use copy
instead.
copy_nonoverlapping
is semantically
equivalent to
memcpy
, but with the argument order swapped.
The copy is “untyped” in the sense that data may be uninitialized or
otherwise violate the requirements of T
. The initialization state is
preserved exactly.
Panics
This function will panic if the number of bytes, count * size_of<T>()
,
overflows.
Safety
Behavior is undefined if any of the following conditions are violated:
src
must be valid for reads ofcount * size_of<T>()
bytes.dst
must be valid for writes ofcount * size_of<T>()
bytes.- The region of memory beginning at
src
with a size ofcount * size_of<T>()
bytes must not overlap with the region of memory beginning atdst
with the same size. dst
must not have an overlapping object in its tail padding. Ifdst
is in an array, or was heap allocated, then this will always be satisfied.
Like copy
,
copy_nonoverlapping
creates a bitwise
copy of T
,
regardless of whether T
is TrivialCopy
or TriviallyRelocatable
. If T
is not TrivialCopy
, using the value in
*dst
can violate memory safety.
If T
is not TriviallyRelocatable
,
using both the values in *src
and in *dst
can violate memory safety.
Note that even if the effectively copied size (count * size_of<T>()
) is 0,
the pointers must be non-null and properly aligned.