Updated nlohmann::basicjson::operator[] (markdown)
1 parent
e79f539583
commit
4ceb25bcda
1 file changed
+8
-6
@@ -9,9 +9,9 @@ const_reference operator[](const object_t::key_type& key) const // 4
|
||||
|
||||
## Description
|
||||
|
||||
1. Returns a reference to the element at specified index `idx`. No bounds checking is performed. In case `idx > size()`, null values are inserted between `size()` and `idx - 1` (only works for arrays).
|
||||
1. Returns a reference to the element at specified index `idx`. In case `idx > size()`, null values are inserted between `size()` and `idx` before (only works for arrays).
|
||||
2. Returns a reference to the element at specified index `idx`. No bounds checking is performed and no values will be inserted (only works for arrays).
|
||||
3. Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion if such key does not already exist. If an insertion is performed, the mapped value is value-initialized (default-constructed for class types, zero-initialized otherwise) and a reference to it is returned. No bounds checking is performed (only works for objects).
|
||||
3. Returns a reference to the value that is mapped to a key equivalent to `key`, performing an insertion of a null value if such key does not already exist and returns a reference to this value (only works for objects).
|
||||
4. Returns a reference to the mapped value of the element with key equivalent to `key`. No bounds checking is performed and no values will be inserted (only works for objects).
|
||||
|
||||
## Parameters
|
||||
@@ -21,14 +21,16 @@ const_reference operator[](const object_t::key_type& key) const // 4
|
||||
|
||||
## Return value
|
||||
|
||||
Reference to the specified value.
|
||||
Reference to the specified value. In case of 1 and 3, the reference may be to a newly inserted null value.
|
||||
|
||||
## Complexity
|
||||
|
||||
1. Constant.
|
||||
2. Logarithmic in the size of the container.
|
||||
1. Linear in the distance between `size()` and `idx` if `idx > size()`, constant otherwise.
|
||||
2. Constant.
|
||||
3. Logarithmic in the size of the container.
|
||||
4. Logarithmic in the size of the container.
|
||||
|
||||
## Exceptions
|
||||
|
||||
1. `std::runtime_error` when called on a JSON container with other type than `array`.
|
||||
2. `std::runtime_error` when called on a JSON container with other type than `object`.
|
||||
2. `std::runtime_error` when called on a JSON container with other type than `object`.
|
||||
Reference in new issue
Block a user