MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / emplace_back

Function emplace_back

Source/Utils/json.hpp:21900–21923  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21898 */
21899 template<class... Args>
21900 reference emplace_back(Args&& ... args)
21901 {
21902 // emplace_back only works for null objects or arrays
21903 if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
21904 {
21905 JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
21906 }
21907
21908 // transform null object into an array
21909 if (is_null())
21910 {
21911 m_type = value_t::array;
21912 m_value = value_t::array;
21913 assert_invariant();
21914 }
21915
21916 // add element to array (perfect forwarding)
21917#ifdef JSON_HAS_CPP_17
21918 return m_value.array->emplace_back(std::forward<Args>(args)...);
21919#else
21920 m_value.array->emplace_back(std::forward<Args>(args)...);
21921 return m_value.array->back();
21922#endif
21923 }
21924
21925 /*!
21926 @brief add an object to an object if key does not exist

Callers 1

emplaceMethod · 0.85

Calls 5

is_nullFunction · 0.85
is_arrayFunction · 0.85
createFunction · 0.85
type_nameFunction · 0.85
assert_invariantFunction · 0.85

Tested by

no test coverage detected