|
rstd 0.1.0
|
Public Member Functions | |
| ~MaybeUninit ()=default | |
| Destructor does nothing - it never calls T's destructor. | |
| constexpr auto | write (T &&val) noexcept(meta::is_nothrow_move_constructible_v< T >) -> T & |
| constexpr auto | as_ptr () const noexcept -> const T * |
| constexpr auto | as_mut_ptr () noexcept -> T * |
| constexpr auto | assume_init () &&noexcept -> T requires(meta::is_move_constructible_v< T >) |
| constexpr auto | assume_init_read () const noexcept -> T requires(meta::is_copy_constructible_v< T >) |
| constexpr auto | assume_init_ref () const noexcept -> const T & |
| constexpr auto | assume_init_mut () noexcept -> T & |
| constexpr void | assume_init_drop () noexcept |
Static Public Member Functions | |
| static constexpr auto | make (T &&val) noexcept(meta::is_nothrow_move_constructible_v< T >) -> MaybeUninit |
| static constexpr auto | uninit () noexcept -> MaybeUninit |
| static constexpr auto | zeroed () noexcept -> MaybeUninit |
A wrapper type to construct uninitialized instances of T.
This is useful for constructing uninitialized data that is later initialized. Unlike direct use of uninitialized memory, MaybeUninit<T> signals to the compiler that the data here might not be initialized.
Note that dropping a MaybeUninit<T> will never call T's destructor. It is your responsibility to make sure T gets destroyed if it got initialized.
|
inlineconstexprexportnoexcept |
Gets a mutable pointer to the contained value. Reading from this pointer or dereferencing it is undefined behavior unless the MaybeUninit<T> is initialized.
|
inlineconstexprexportnoexcept |
Gets a const pointer to the contained value. Reading from this pointer or dereferencing it is undefined behavior unless the MaybeUninit<T> is initialized.
|
inlineconstexprexportnoexcept |
Extracts the value from the MaybeUninit<T> container by move.
It is up to the caller to guarantee that the MaybeUninit<T> really is in an initialized state. Calling this when the content is not yet fully initialized causes undefined behavior.
|
inlineconstexprexportnoexcept |
Drops the contained value in place.
It is up to the caller to guarantee that the MaybeUninit<T> really is in an initialized state. Calling this when the content is not yet fully initialized causes undefined behavior.
|
inlineconstexprexportnoexcept |
Gets a mutable reference to the contained value.
Calling this when the content is not yet fully initialized causes undefined behavior: it is up to the caller to guarantee that the MaybeUninit<T> really is in an initialized state.
|
inlineconstexprexportnoexcept |
Extracts the value from the MaybeUninit<T> container by copy.
It is up to the caller to guarantee that the MaybeUninit<T> really is in an initialized state. Calling this when the content is not yet fully initialized causes undefined behavior.
|
inlineconstexprexportnoexcept |
Gets a const reference to the contained value.
Calling this when the content is not yet fully initialized causes undefined behavior: it is up to the caller to guarantee that the MaybeUninit<T> really is in an initialized state.
|
inlinestaticconstexprexportnoexcept |
Creates a new MaybeUninit<T> initialized with the given value. It is safe to call assume_init() on the return value of this function.
Note that dropping a MaybeUninit<T> will never call T's destructor. It is your responsibility to make sure T gets destroyed if it got initialized.
|
inlinestaticconstexprexportnoexcept |
Creates a new MaybeUninit<T> in an uninitialized state.
Note that dropping a MaybeUninit<T> will never call T's destructor. It is your responsibility to make sure T gets destroyed if it got initialized.
|
inlineconstexprexportnoexcept |
Sets the value of the MaybeUninit<T>.
This overwrites any previous value without dropping it, so be careful not to use this twice unless you want to skip running the destructor. For your convenience, this also returns a mutable reference to the (now safely initialized) contents.
|
inlinestaticconstexprexportnoexcept |
Creates a new MaybeUninit<T> in an uninitialized state, with the memory being filled with 0 bytes.
Note that if T has padding bytes, those bytes may not be zeroed. It depends on T whether that already makes for proper initialization.