struct NeverValueAccess

Declaration

template <class T>
struct NeverValueAccess { /* full declaration omitted */ };

Description

A helper class that constructs and holds a NeverValueField type T. Default-constructing NeverValueAccess will construct T with the never value set. The other constructors allow constructing the T from a parameter (typically a const T & or T & & ). Provides methods to see if the T is in the never-value state or not, and to set the never-value field to: * the never-value, after trivial default construction. * the destroy-value before destroying it from the never-value state. A type which satisfies NeverValueField has a field which is never set to a specific value during its lifetime under normal use. The type provides a private way construct it with that never-value in the field as a signal to say the type is not really constructed/present. The destructor must be a no-op when being destroyed from the never-value state. To help make that easier, a separate "destroy value" can be specified which the never-value field is set to before calling the destructor so that the destructor does not need to handle the never-value. # Safety To implement NeverValueAccess, a type must: * Insert a call to the sus_class_never_value_field() macro inside its body, which takes as parameters the NeverValue configuration of the type. * Be (optionally-constexpr-) constructible from NeverValueConstructor, which sets the NeverValue and leaves the type in a state that can be destructed later as a no-op. * The above constructor must be `private` to prevent incorrect access.

Declared at: sus/mem/never_value.h:85

Templates

T

Method Overview

Methods

NeverValueAccess<T>()

Declared at: sus/mem/never_value.h:86

template <class... U>
constexpr NeverValueAccess<T>(U&&... v)

Declared at: sus/mem/never_value.h:90

Templates

U

Parameters

U&&... v

inline constexpr const T& as_inner() const

Declared at: sus/mem/never_value.h:108

inline constexpr T& as_inner_mut()

Declared at: sus/mem/never_value.h:111

inline constexpr bool is_constructed()
    const noexcept

Description

Checks if the never-value field is set to the never-value, returning false if it is.

Declared at: sus/mem/never_value.h:94

inline constexpr void set_destroy_value(
    ::sus::marker::UnsafeFnMarker) noexcept

Description

Sets the never-value field to the destroy-value.

Declared at: sus/mem/never_value.h:101

Parameters

::sus::marker::UnsafeFnMarker