Skip to content

Commit ceadea5

Browse files
authored
add emplace
1 parent c45adda commit ceadea5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cppjson/include/cppjson/object.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ namespace cppjson
156156
return Object::ObjectProxy{ this->_objects.emplace_back() };
157157
}
158158

159+
Object::ObjectProxy EmplaceBack(const auto& object = nullptr)
160+
{
161+
if constexpr(std::same_as<decltype(object), std::nullptr_t>)
162+
return Object::ObjectProxy{ this->_objects.emplace_back() };
163+
else return Object::ObjectProxy{ this->_objects.emplace_back(object) };
164+
}
165+
159166
Object::ObjectProxy operator[](const int index)
160167
{
161168
if (index >= this->_objects.size()) throw std::logic_error("Out of bound");

0 commit comments

Comments
 (0)