| 17713 | */ |
| 17714 | template<class... Args> |
| 17715 | void emplace_back(Args&& ... args) |
| 17716 | { |
| 17717 | // emplace_back only works for null objects or arrays |
| 17718 | if (JSON_UNLIKELY(not(is_null() or is_array()))) |
| 17719 | { |
| 17720 | JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()))); |
| 17721 | } |
| 17722 | |
| 17723 | // transform null object into an array |
| 17724 | if (is_null()) |
| 17725 | { |
| 17726 | m_type = value_t::array; |
| 17727 | m_value = value_t::array; |
| 17728 | assert_invariant(); |
| 17729 | } |
| 17730 | |
| 17731 | // add element to array (perfect forwarding) |
| 17732 | m_value.array->emplace_back(std::forward<Args>(args)...); |
| 17733 | } |
| 17734 | |
| 17735 | /*! |
| 17736 | @brief add an object to an object if key does not exist |
nothing calls this directly
no test coverage detected