Reflection module

range_check_and_store

procedureSource

Stores value at pointer as the integer type info describes, if it fits. Returns whether it did, and the lowest and highest value of that type.

range_check_and_store :: (
    value: $T,
    info: *Type_Info_Integer,
    pointer: *void
) -> (success: bool, low: T, high: T)

Parameters

value: $T
info: *Type_Info_Integer
pointer: *void

Returns

success: bool
low: T
high: T
Example↗
small: u8;
ok := range_check_and_store(200, cast(*Type_Info_Integer) type_info(u8), *small);
assert(ok && small == 200);
ok = range_check_and_store(300, cast(*Type_Info_Integer) type_info(u8), *small);
assert(!ok && small == 200);

See also