MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / insert

Function insert

lesson6-Segmentation/json.hpp:22022–22038  ·  view source on GitHub ↗

! @brief inserts element Inserts element @a val before iterator @a pos. @param[in] pos iterator before which the content will be inserted; may be the end() iterator @param[in] val element to insert @return iterator pointing to the inserted @a val. @throw type_error.309 if called on JSON values other than arrays; example: `"cannot use insert() with string"` @t

Source from the content-addressed store, hash-verified

22020 @since version 1.0.0
22021 */
22022 iterator insert(const_iterator pos, const basic_json& val)
22023 {
22024 // insert only works for arrays
22025 if (JSON_HEDLEY_LIKELY(is_array()))
22026 {
22027 // check if iterator pos fits to this JSON value
22028 if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
22029 {
22030 JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
22031 }
22032
22033 // insert to array and return iterator
22034 return insert_iterator(pos, val);
22035 }
22036
22037 JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
22038 }
22039
22040 /*!
22041 @brief inserts element

Callers

nothing calls this directly

Calls 8

is_arrayFunction · 0.85
createFunction · 0.85
insert_iteratorFunction · 0.85
type_nameFunction · 0.85
is_objectFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected