Skip to main content

function

initialize_pointee_copy

initialize_pointee_copy[T: Copyable](ptr: UnsafePointer[T, 0], value: T)

Emplace a copy of value into the pointer location.

The pointer memory location is assumed to contain uninitialized data, and consequently the current contents of this pointer are not destructed before writing value. Similarly, ownership of value is logically transferred into the pointer location.

When compared to initialize_pointee_move, this avoids an extra move on the callee side when the value must be copied.

Parameters:

  • T (Copyable): The type the pointer points to, which must be Copyable.

Args:

  • ptr (UnsafePointer[T, 0]): The pointer to initialize through.
  • value (T): The value to emplace.