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
- safe_addr::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.
- safe_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::safe_addr(x: auto(T) const& ==const) : T?#()
returns temporary pointer to the given expression
- Arguments
x : auto(T)&!
- safe_addr::safe_addr(x: auto(T)& ==const) : T?#()