11.6. safe_addr macro
The SAFE_ADDR module provides compile-time checked pointer operations.
safe_addr returns a temporary pointer to a variable only if the compiler
can verify the pointer will not outlive its target. This prevents dangling
pointer bugs without runtime overhead.
All functions and symbols are in “safe_addr” module, use require to get access to it.
require daslib/safe_addr
11.6.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.
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.
11.6.2. Safe temporary address
11.6.2.1. safe_addr
- safe_addr(x: auto(T) const& ==const): T?#
returns temporary pointer to the given expression
- Arguments:
x : auto(T)&!
- safe_addr(x: auto(T)& ==const): T?#
11.6.3. Temporary pointers
11.6.3.1. temp_ptr
- temp_ptr(x: auto(T)? implicit ==const): T?#
returns temporary pointer from a given pointer
- Arguments:
x : auto(T)? implicit!
- temp_ptr(x: auto(T)? const implicit ==const): T?#
11.6.4. Temporary values
11.6.4.1. temp_value
- temp_value(x: auto(T)& ==const): T&#
returns temporary reference to the given expression
- Arguments:
x : auto(T)&!
- temp_value(x: auto(T) const& ==const): T const&#