Home | Libraries | People | FAQ | More |
Dynamic variables can be created in various ways.
Expression |
Semantics |
Conditions |
---|---|---|
|
Creates a nullable variable. |
Effects: Default-initializes variable to the nullable type. Example:
// Default-initializes to nullable type dynamic::variable data; assert(data.is<dynamic::nullable>());
|
|
Creates a variable of given supported type. |
Requires:
Effects: Direct-initializes variable to value. Example:
// Direct-initializes to integer type dynamic::variable data(1); assert(data.is<int>());
|
|
Creates a copy of another dynamic variable. |
Effects: Copy-initializes variable with the type and value from another dynamic variable. Example:
// Copy-initializes from other value dynamic::variable other(3.0); dynamic::variable data(other); assert(data.is<double>());
|
|
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:
// List-initializes heterogenous array from initializer list dynamic::variable data { null, true, 2, 3.0, "alpha" }; assert(data.is<dynamic::array>());
// List-initializes nested integer array from initializer list dynamic::variable data { 1, 2, { 3, 4 }, 5 }; assert(data.is<dynamic::array>());
|
|
Creates an associative array from initializer list. |
Requires: Initializer list shall be a sequence of pairs[a]. 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:
// List-initializes associative array from initializer list dynamic::variable data { { "alpha", 1 }, { "bravo", 2 } }; assert(data.is<dynamic::map>());
|
Creates an array from factory method. |
||
Creates an associative array from factory method. |
||
[a] A pair is a dynamic variable containing an array with exactly two dynamic variables. |
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);
Function |
Returns |
Description |
---|---|---|
|
|
Returns true if the variable is empty or nullable; return false otherwise. |
|
|
|
|
|
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 [ |
|