35. safe_addr macro

The safe_addr module implements safe_addr pattern, which returns temporary address of local expression.

All functions and symbols are in “safe_addr” module, use require to get access to it.

require daslib/safe_addr

35.1. Function annotations

SafeAddrMacro

This macro reports an error if safe_addr is attempted on the object, which is not local to the scope. I.e. if the object can expire while in scope, with delete, garbage collection, or on the C++ side.

SharedAddrMacro

This macro reports an error if shared_addr is attempted on anything other that shared global variables. I.e. only global variables are safe to use with shared_addr.

TempValueMacro

This macro reports an error if temp_value is attempted outside of function arguments.

35.2. Safe temporary address

safe_addr(x: auto(T)& ==const) : T?#()

returns temporary pointer to the given expression

Arguments
  • x : auto(T)&!

safe_addr(x: auto(T) const& ==const) : T?#()

returns temporary pointer to the given expressio

Arguments
  • x : auto(T)&!

shared_addr(tab: table<auto(KEY), auto(VAL)>; k: KEY) : auto()

returns address of the given shared variable. it’s safe because shared variables never go out of scope

Arguments
  • tab : table<auto(KEY);auto(VAL)>

  • k : KEY

shared_addr(val: auto(VALUE)) : auto()

returns address of the given shared variable. it’s safe because shared variables never go out of scope

Arguments
  • val : auto(VALUE)&

35.3. Temporary pointers

temp_ptr(x: auto(T)? const implicit ==const) : T?#()

returns temporary pointer from a given pointer

Arguments
  • x : auto(T)? implicit!

temp_ptr(x: auto(T)? implicit ==const) : T?#()

returns temporary pointer from a given pointer

Arguments
  • x : auto(T)? implicit!

35.4. Uncategorized

temp_value(x: auto(T) const& ==const) : T const&#()

returns temporary pointer to the given expression

Arguments
  • x : auto(T)&!

temp_value(x: auto(T)& ==const) : T&#()

returns temporary pointer to the given expression

Arguments
  • x : auto(T)&!