mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 02:36:18 +08:00
Added support for std::unique_ptr and rfl::Box
This commit is contained in:
@@ -13,20 +13,21 @@ void test_array() {
|
||||
struct Person {
|
||||
rfl::Field<"firstName", std::string> first_name;
|
||||
rfl::Field<"lastName", std::string> last_name = "Simpson";
|
||||
rfl::Field<"children", std::shared_ptr<std::array<Person, 3>>>
|
||||
rfl::Field<"children", std::unique_ptr<std::array<Person, 3>>>
|
||||
children = rfl::default_value;
|
||||
};
|
||||
|
||||
const auto bart = Person{.first_name = "Bart"};
|
||||
auto bart = Person{.first_name = "Bart"};
|
||||
|
||||
const auto lisa = Person{.first_name = "Lisa"};
|
||||
auto lisa = Person{.first_name = "Lisa"};
|
||||
|
||||
const auto maggie = Person{.first_name = "Maggie"};
|
||||
auto maggie = Person{.first_name = "Maggie"};
|
||||
|
||||
const auto homer =
|
||||
Person{.first_name = "Homer",
|
||||
.children = std::make_shared<std::array<Person, 3>>(
|
||||
std::array<Person, 3>{bart, lisa, maggie})};
|
||||
const auto homer = Person{
|
||||
.first_name = "Homer",
|
||||
.children =
|
||||
std::make_unique<std::array<Person, 3>>(std::array<Person, 3>{
|
||||
std::move(bart), std::move(lisa), std::move(maggie)})};
|
||||
|
||||
write_and_read(
|
||||
homer,
|
||||
|
||||
Reference in New Issue
Block a user