MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / at

Function at

3rd/json/include/nlohmann/json.hpp:15680–15694  ·  view source on GitHub ↗

! @brief access specified array element with bounds checking Returns a reference to the element at specified location @a idx, with bounds checking. @param[in] idx index of the element to access @return reference to the element at index @a idx @throw type_error.304 if the JSON value is not an array; in this case, calling `at` with an index makes no sense. See exampl

Source from the content-addressed store, hash-verified

15678 can be thrown.,at__size_type}
15679 */
15680 reference at(size_type idx)
15681 {
15682 // at only works for arrays
15683 if (JSON_LIKELY(is_array()))
15684 {
15685 JSON_TRY
15686 {
15687 return m_value.array->at(idx);
15688 }
15689 JSON_CATCH (std::out_of_range&)
15690 {
15691 // create better exception explanation
15692 JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
15693 }
15694 }
15695 else
15696 {
15697 JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));

Callers

nothing calls this directly

Calls 2

is_arrayFunction · 0.85
is_objectFunction · 0.85

Tested by

no test coverage detected