MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / emplace_back

Function emplace_back

Source/external/json.hpp:22379–22399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22377 /// @sa https://json.nlohmann.me/api/basic_json/emplace_back/
22378 template<class... Args>
22379 reference emplace_back(Args&& ... args)
22380 {
22381 // emplace_back only works for null objects or arrays
22382 if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
22383 {
22384 JSON_THROW(type_error::create(311, detail::concat("cannot use emplace_back() with ", type_name()), this));
22385 }
22386
22387 // transform null object into an array
22388 if (is_null())
22389 {
22390 m_type = value_t::array;
22391 m_value = value_t::array;
22392 assert_invariant();
22393 }
22394
22395 // add element to array (perfect forwarding)
22396 const auto old_capacity = m_value.array->capacity();
22397 m_value.array->emplace_back(std::forward<Args>(args)...);
22398 return set_parent(m_value.array->back(), old_capacity);
22399 }
22400
22401 /// @brief add an object to an object if key does not exist
22402 /// @sa https://json.nlohmann.me/api/basic_json/emplace/

Callers 1

emplaceFunction · 0.85

Calls 7

is_nullFunction · 0.85
is_arrayFunction · 0.85
createFunction · 0.85
concatFunction · 0.85
type_nameFunction · 0.85
set_parentFunction · 0.85
capacityMethod · 0.80

Tested by

no test coverage detected