iyi

Standard library, 0.18.0

std/reference_storage

ReferenceStorage(T) provides the minimum storage for the instance data of an object of type T. The compiler guarantees that sizeof(ReferenceStorage(T)) == instance_sizeof(T).

import std/reference_storage to use it. Source: src/std/reference_storage.iyi at v0.18.0.

T must be a non-union reference type.

WARNING: ReferenceStorage is for manual memory management, such as allocating an instance on the stack or with a custom arena allocator.

ReferenceStorage(T)struct

std/reference_storageiyi doc src/std/reference_storage.iyi
pub struct ReferenceStorage(T) < Value
  # Field-wise, with class fields compared by identity. `T#==` on a
  # `String` field follows the pointer, so uninitialized storage died of
  # a memory fault; two storages with equal string contents at different
  # addresses compared equal while `hash` mixed the pointer bytes. Whole-
  # blob compare is also wrong: `other` is passed by value and padding
  # bytes are not copied, so two constructed `Node`s compared unequal.
  def ==(other : ReferenceStorage(T)) : Bool
  def ==(other : Object) : Bool
  # Field by field, exactly as `==` compares: a class field by its
  # identity, any other by its own `hash`, mixed with a wrapping step
  # (checked `h * 31` panicked once `instance_sizeof(T)` passed a few
  # bytes). Mixing the raw bytes disagreed with `==`: a `Float64` field
  # holding `0.0` and one holding `-0.0` compare equal and differ in their
  # sign bit, and a `String?` field compares by content while its bytes
  # are the pointer, so equal storages hashed apart.
  def hash : Int32
  def initialize
  def inspect : String
  def to_reference : T
  def to_s : String
end

Referenceclass, reopened

std/reference_storageiyi doc src/std/reference_storage.iyi
class ::Reference
  def self.pre_initialize(address : Pointer)
  def self.unsafe_construct(address : Pointer, *args, **opts) : self
end