@brief inserts element into array @sa https://json.nlohmann.me/api/basic_json/insert/
| 3312 | /// @brief inserts element into array |
| 3313 | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
| 3314 | iterator insert(const_iterator pos, const basic_json& val) // NOLINT(performance-unnecessary-value-param) |
| 3315 | { |
| 3316 | // insert only works for arrays |
| 3317 | if (JSON_HEDLEY_LIKELY(is_array())) |
| 3318 | { |
| 3319 | // check if iterator pos fits to this JSON value |
| 3320 | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
| 3321 | { |
| 3322 | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this)); |
| 3323 | } |
| 3324 | |
| 3325 | // insert to array and return iterator |
| 3326 | return insert_iterator(pos, val); |
| 3327 | } |
| 3328 | |
| 3329 | JSON_THROW(type_error::create(309, detail::concat("cannot use insert() with ", type_name()), this)); |
| 3330 | } |
| 3331 | |
| 3332 | /// @brief inserts element into array |
| 3333 | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
nothing calls this directly
no test coverage detected