|
| 1 | +### `tao::json::basic_value::at` |
| 2 | + |
| 3 | +```c++ |
| 4 | +basic_value& at( std::size_t pos ); // (1) |
| 5 | +const basic_value& at( std::size_t pos ) const; // (2) |
| 6 | +basic_value& at( const std::string& key ); // (3) |
| 7 | +const basic_value& at( const std::string& key ) const; // (4) |
| 8 | + |
| 9 | +basic_value& at( const json::pointer& jp ); // (5) |
| 10 | +const basic_value& at( const json::pointer& jp ) const; // (6) |
| 11 | + |
| 12 | +basic_value& unsafe_at( std::size_t pos ); // (7) |
| 13 | +const basic_value& unsafe_at( std::size_t pos ) const; // (8) |
| 14 | +basic_value& unsafe_at( const std::string& key ); // (9) |
| 15 | +const basic_value& unsafe_at( const std::string& key ) const; // (10) |
| 16 | +``` |
| 17 | +
|
| 18 | +1), 2): Returns a reference to the array element at specified location `pos`, with bounds checking. |
| 19 | +3), 4): Returns a reference to the mapped value of the object element with key equivalent to `key`, with bounds checking. |
| 20 | +5), 6): Returns a reference to the element specified by the JSON Pointer `js`, with bounds checking. |
| 21 | +7), 8): Returns a reference to the array element at specified location `pos`. |
| 22 | +9), 10): Returns a reference to the mapped value of the object element with key equivalent to `key`. |
| 23 | +
|
| 24 | +#### Preconditions |
| 25 | +
|
| 26 | +The instance must *not* be in a discarded state. |
| 27 | +
|
| 28 | +1. - |
| 29 | +2. - |
| 30 | +3. - |
| 31 | +4. - |
| 32 | +5. - |
| 33 | +6. - |
| 34 | +7. `type() == json::type::ARRAY` and `pos` must be within range |
| 35 | +8. `type() == json::type::ARRAY` and `pos` must be within range |
| 36 | +9. `type() == json::type::OBJECT` and an element with key equivalent to `key` must exist |
| 37 | +10. `type() == json::type::OBJECT` and an element with key equivalent to `key` must exist |
| 38 | +
|
| 39 | +#### Return value |
| 40 | +
|
| 41 | +A reference to the specified element. |
| 42 | +
|
| 43 | +#### Exceptions |
| 44 | +
|
| 45 | +1. `std::logic_error` if `type() != json::type::ARRAY`, `std::out_of_range` if `pos < get_array().size()` |
| 46 | +2. `std::logic_error` if `type() != json::type::ARRAY`, `std::out_of_range` if `pos < get_array().size()` |
| 47 | +3. `std::logic_error` if `type() != json::type::OBJECT`, `std::out_of_range` if the container does not have an element with the specified key. |
| 48 | +4. `std::logic_error` if `type() != json::type::OBJECT`, `std::out_of_range` if the container does not have an element with the specified key. |
| 49 | +5. TODO |
| 50 | +6. TODO |
| 51 | +7. `noexcept` |
| 52 | +8. `noexcept` |
| 53 | +9. `noexcept` |
| 54 | +10. `noexcept` |
| 55 | +
|
| 56 | +#### Complexity |
| 57 | +
|
| 58 | +1. Constant |
| 59 | +2. Constant |
| 60 | +3. Logarithmic in the size of the object container |
| 61 | +4. Logarithmic in the size of the object container |
| 62 | +5. TODO |
| 63 | +6. TODO |
| 64 | +7. Constant |
| 65 | +8. Constant |
| 66 | +9. Logarithmic in the size of the object container |
| 67 | +10. Logarithmic in the size of the object container |
0 commit comments