@brief inserts element into array @sa https://json.nlohmann.me/api/basic_json/insert/
| 3019 | /// @brief inserts element into array |
| 3020 | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |
| 3021 | iterator insert(const_iterator pos, const basic_json& val) |
| 3022 | { |
| 3023 | // insert only works for arrays |
| 3024 | if (JSON_HEDLEY_LIKELY(is_array())) |
| 3025 | { |
| 3026 | // check if iterator pos fits to this JSON value |
| 3027 | if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) |
| 3028 | { |
| 3029 | JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); |
| 3030 | } |
| 3031 | |
| 3032 | // insert to array and return iterator |
| 3033 | return insert_iterator(pos, val); |
| 3034 | } |
| 3035 | |
| 3036 | JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); |
| 3037 | } |
| 3038 | |
| 3039 | /// @brief inserts element into array |
| 3040 | /// @sa https://json.nlohmann.me/api/basic_json/insert/ |