MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / insert

Function insert

3rd/nlohmann_json/include/nlohmann/json.hpp:5765–5781  ·  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

5763 @since version 1.0.0
5764 */
5765 iterator insert(const_iterator pos, const basic_json& val)
5766 {
5767 // insert only works for arrays
5768 if (JSON_HEDLEY_LIKELY(is_array()))
5769 {
5770 // check if iterator pos fits to this JSON value
5771 if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
5772 {
5773 JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this));
5774 }
5775
5776 // insert to array and return iterator
5777 return insert_iterator(pos, val);
5778 }
5779
5780 JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this));
5781 }
5782
5783 /*!
5784 @brief inserts element

Callers 1

insertMethod · 0.70

Calls 9

stringFunction · 0.85
is_arrayFunction · 0.70
createFunction · 0.70
insert_iteratorFunction · 0.70
type_nameFunction · 0.70
is_objectFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected