template <class T>
void copy(::sus::marker::UnsafeFnMarker,
          const T* src,
          T* dst,
          ::sus::num::usize count) noexcept

Description

Copies `count * size_of <T >()` bytes from `src` to `dst`. The source and destination may overlap. If the source and destination will never overlap, [`copy_nonoverlapping`]($sus::ptr::copy_nonoverlapping) can be used instead. [`copy`]($sus::ptr::copy) is semantically equivalent to [`memmove`](https://en.cppreference.com/w/c/string/byte/memmove), but with the argument order swapped. Copying takes place as if the bytes were copied from `src` to a temporary array and then copied from the array to `dst`. 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 of `count * size_of <T >()` bytes. * `dst` must be valid for writes of `count * size_of <T >()` bytes. * `dst` must not have an overlapping object in its tail padding. If `dst` is in an array, or was heap allocated, then this will always be satisfied. [`copy`]($sus::ptr::copy) creates a bitwise copy of `T`, regardless of whether `T` is [`TrivialCopy`]($sus::mem::TrivialCopy) or [`TriviallyRelocatable`]($sus::mem::TriviallyRelocatable). If `T` is not [`TrivialCopy`]($sus::mem::TrivialCopy), using the value in `*dst` can violate memory safety. If `T` is not [`TriviallyRelocatable`]($sus::mem::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.

Declared at: sus/ptr/copy.h:129

Templates

T

Parameters

::sus::marker::UnsafeFnMarker
const T* src
T* dst
::sus::num::usize count