MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / insert

Method insert

extern/json/json.hpp:5078–5098  ·  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 std::domain_error if called on JSON values other than arrays; example: `"cannot use insert() with string"`

Source from the content-addressed store, hash-verified

5076 @since version 1.0.0
5077 */
5078 iterator insert(const_iterator pos, const basic_json& val)
5079 {
5080 // insert only works for arrays
5081 if (is_array())
5082 {
5083 // check if iterator pos fits to this JSON value
5084 if (pos.m_object != this)
5085 {
5086 throw std::domain_error("iterator does not fit current value");
5087 }
5088
5089 // insert to array and return iterator
5090 iterator result(this);
5091 result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, val);
5092 return result;
5093 }
5094 else
5095 {
5096 throw std::domain_error("cannot use insert() with " + type_name());
5097 }
5098 }
5099
5100 /*!
5101 @brief inserts element

Callers 11

unflattenListFunction · 0.45
GetIntRefMethod · 0.45
GetFloatRefMethod · 0.45
GetVoidPtrRefMethod · 0.45
SetIntMethod · 0.45
SetFloatMethod · 0.45
SetVoidPtrMethod · 0.45
operator[]Method · 0.45
push_backMethod · 0.45
patchMethod · 0.45
diffMethod · 0.45

Calls 1

insertFunction · 0.85

Tested by

no test coverage detected