§tiro::handle

A handle represents a reference to an object. More...

#include "tiropp/objects.hpp"

Inherited by array, boolean, coroutine, exception, float_, function, integer, module, native, null, record, record_schema, result, string, tuple, type

§Protected Classes

Name
structcheck_kind_t

§Public Functions

Name
template <typename T >
T
as() const
Converts this value to the target type.
template <typename T >
T
as()
Converts this value to the target type.
handle(tiro_vm_t raw_vm)
Constructs a new handle instance.
handle(const handle & other)
Constructs a new handle and initialize is it with the same value as other.
handle(handle && other) =default
Move constructs a handle.
~handle() =default
handle &operator=(const handle & other)
Copy assigns a handle.
handle &operator=(handle && other) =default
Move assigns a handle.
boolvalid() const
Returns true if this handle points to an object (i.e. it was not moved from).
value_kindkind() const
Returns the kind of the value currently held by this handle.
template <typename T >
bool
is() const
Returns true if this value is of the target type.
typetype_of() const
Returns the type of the value currently held by this handle.
stringto_string() const
Returns a string that represents the current value.
tiro_vm_traw_vm() const
Returns the raw vm instance associated with this handle.
tiro_handle_traw_handle() const
Returns the raw handle instance (nullptr for invalid handles).

§Protected Functions

Name
handle(check_kind_t , handle && other, value_kind expected)

§Protected Attributes

Name
constexpr check_kind_tcheck_kind

§Detailed Description

class tiro::handle;

A handle represents a reference to an object.

Valid handles point to an object slot which is managed by the tiro runtime. All handles internally refer to the virtual machine they belong to.

§Public Functions Documentation

§function as

template <typename T >
inline T as() const

Converts this value to the target type.

§function as

template <typename T >
inline T as()

Converts this value to the target type.

§function handle

inline explicit handle(
tiro_vm_t raw_vm
)

Constructs a new handle instance.

Precondition: raw_vm != nullptr.

The handle will belong to the given virtual machine and will be initialized with null.

§function handle

inline handle(
const handle & other
)

Constructs a new handle and initialize is it with the same value as other.

If other is invalid, then the new handle will also become invalid.

§function handle

handle(
handle && other
) =default

Move constructs a handle.

The other handle will become invalid: it may not longer be used for any operations other than destruction and assignments.

§function ~handle

~handle() =default

§function operator=

inline handle & operator=(
const handle & other
)

Copy assigns a handle.

This handle will contain the same value as other. If other was invalid, then this handle will also become invalid.

§function operator=

handle & operator=(
handle && other
) =default

Move assigns a handle.

The other handle will become invalid: it may not longer be used for any operations other than destruction and assignments.

§function valid

inline bool valid() const

Returns true if this handle points to an object (i.e. it was not moved from).

§function kind

inline value_kind kind() const

Returns the kind of the value currently held by this handle.

§function is

template <typename T >
inline bool is() const

Returns true if this value is of the target type.

§function type_of

inline type type_of() const

Returns the type of the value currently held by this handle.

§function to_string

inline string to_string() const

Returns a string that represents the current value.

§function raw_vm

inline tiro_vm_t raw_vm() const

Returns the raw vm instance associated with this handle.

§function raw_handle

inline tiro_handle_t raw_handle() const

Returns the raw handle instance (nullptr for invalid handles).

§Protected Functions Documentation

§function handle

inline handle(
check_kind_t ,
handle && other,
value_kind expected
)

§Protected Attributes Documentation

§variable check_kind

static constexpr check_kind_t check_kind {};

Updated on 2022-02-27 at 21:17:13 +0100