MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / push_back

Function push_back

src/include/nlohmann/json.hpp:3117–3138  ·  view source on GitHub ↗

@brief add an object to an array @sa https://json.nlohmann.me/api/basic_json/push_back/

Source from the content-addressed store, hash-verified

3115 /// @brief add an object to an array
3116 /// @sa https://json.nlohmann.me/api/basic_json/push_back/
3117 void push_back(basic_json&& val)
3118 {
3119 // push_back only works for null objects or arrays
3120 if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
3121 {
3122 JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this));
3123 }
3124
3125 // transform a null object into an array
3126 if (is_null())
3127 {
3128 m_data.m_type = value_t::array;
3129 m_data.m_value = value_t::array;
3130 assert_invariant();
3131 }
3132
3133 // add the element to the array (move semantics)
3134 const auto old_capacity = m_data.m_value.array->capacity();
3135 m_data.m_value.array->push_back(std::move(val));
3136 set_parent(m_data.m_value.array->back(), old_capacity);
3137 // if val is moved from, basic_json move constructor marks it null, so we do not call the destructor
3138 }
3139
3140 /// @brief add an object to an array
3141 /// @sa https://json.nlohmann.me/api/basic_json/operator+=/

Callers 2

operator+=Function · 0.70
insertFunction · 0.70

Calls 14

is_nullFunction · 0.85
is_arrayFunction · 0.85
createFunction · 0.85
concatFunction · 0.85
type_nameFunction · 0.85
set_parentFunction · 0.85
is_objectFunction · 0.85
basic_jsonFunction · 0.85
push_backMethod · 0.80
is_stringMethod · 0.80
moved_or_copiedMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected