Functions
Construction
Dynamic variables can be created in various ways.
Expression |
Semantics |
Conditions |
|
Creates a nullable variable. |
Effects: Default-initializes variable to the nullable type. Example:
|
|
Creates a variable of given supported type. |
Requires:
Effects: Direct-initializes variable to value. Example:
|
|
Creates a copy of another dynamic variable. |
Effects: Copy-initializes variable with the type and value from another dynamic variable. Example:
|
|
Creates an array from initializer list. |
Effects: List-initializes variable as array from initializer list. If the initializer list consists of a sequence of pairs, then the values will be stored as an associative array. Otherwise the values will be stored as an array. Nested lists are allowed. Example:
|
|
Creates an associative array from initializer list. |
Requires: Initializer list shall be a sequence of pairs.[1]. Effects: List-initializes variable as associative array from initializer list. If the initializer list consists of a sequence of pairs, then the values will be stored as an associative array. Otherwise the values will be stored as an array. Nested lists are allowed. Example:
|
Creates an array from factory method. |
||
Creates an associative array from factory method. |
Factory Initialization
Arrays and associated arrays can also be explicitly created with factories.
// Example: List-initializes empty array from factory
auto data = dynamic::array::make();
assert(data.is<dynamic::array>());
assert(data.size() == 0);
// Example: List-initializes array of 42 null values from factory
auto data = dynamic::array::repeat(42, null);
assert(data.is<dynamic::array>());
assert(data.size() == 42);
Capacity
Function |
Returns |
Description |
|
|
Returns true if the variable is empty or nullable; return false otherwise. |
|
|
|
|
|
Acessor
The assume_value() functions have a narrow contract. The requested type T must match the stored type exactly. It is undefined behavior if the pre-condition same<T>() is false.
Function |
Returns |
Description |
|
|
Returns stored element by value. |
|
|
Conversion operator. Same operation as |
|
|
Returns stored element by reference. |
|
|
|
|
|
Looks up element by key |
|
|
Looks up element by integer position |
Function |
Returns |
Description |
|
|
Erases all nested elements.]] |
|
|
Erases element at position |
|
|
Erases all elements in range [ |
|
|
Inserts element |
|
|
Inserts element |
|
|
Inserts elements in range [ |
|
|
Inserts elements in range [ |
|