add dv::list(initializer_list<value>)

This commit is contained in:
MihailRis 2024-09-16 19:43:20 +03:00
parent 2aae28e193
commit 3bc329041a
2 changed files with 7 additions and 4 deletions

View File

@ -295,6 +295,8 @@ namespace dv {
value list(); value list();
value object(); value object();
value list(std::initializer_list<value> values);
} }
#include "util/Buffer.hpp" #include "util/Buffer.hpp"
@ -515,4 +517,8 @@ namespace dv {
value list() { value list() {
return std::make_shared<objects::List>(); return std::make_shared<objects::List>();
} }
value list(std::initializer_list<value> values) {
return std::make_shared<objects::List>(values);
}
} }

View File

@ -10,10 +10,7 @@ TEST(dv, dv) {
auto& obj = list.object(); auto& obj = list.object();
obj["name"] = "user"; obj["name"] = "user";
obj["age"] = 90; obj["age"] = 90;
auto& position = obj.list("position"); obj["position"] = dv::list({40, -41, 52});
position.add(40);
position.add(-41);
position.add(52);
} }
} }
{ {