MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / at

Function at

dependencies/json/json.hpp:19876–19890  ·  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

19874 can be thrown.,at__size_type}
19875 */
19876 reference at(size_type idx)
19877 {
19878 // at only works for arrays
19879 if (JSON_HEDLEY_LIKELY(is_array()))
19880 {
19881 JSON_TRY
19882 {
19883 return m_value.array->at(idx);
19884 }
19885 JSON_CATCH (std::out_of_range&)
19886 {
19887 // create better exception explanation
19888 JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
19889 }
19890 }
19891 else
19892 {
19893 JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));

Callers 1

ordered_mapClass · 0.70

Calls 2

is_arrayFunction · 0.70
is_objectFunction · 0.70

Tested by

no test coverage detected