mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-28 22:06:19 +08:00
34 lines
869 B
C++
34 lines
869 B
C++
#include "test_unique_ptr.hpp"
|
|
|
|
#include <iostream>
|
|
#include <memory>
|
|
#include <rfl.hpp>
|
|
#include <source_location>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "write_and_read.hpp"
|
|
|
|
namespace test_unique_ptr {
|
|
|
|
struct Person {
|
|
rfl::Rename<"firstName", std::string> first_name;
|
|
rfl::Rename<"lastName", std::string> last_name = "Simpson";
|
|
std::unique_ptr<std::vector<Person>> children;
|
|
};
|
|
|
|
void test() {
|
|
std::cout << std::source_location::current().function_name() << std::endl;
|
|
|
|
auto children = std::make_unique<std::vector<Person>>();
|
|
children->emplace_back(Person{.first_name = "Bart"});
|
|
children->emplace_back(Person{.first_name = "Lisa"});
|
|
children->emplace_back(Person{.first_name = "Maggie"});
|
|
|
|
const auto homer =
|
|
Person{.first_name = "Homer", .children = std::move(children)};
|
|
|
|
write_and_read(homer);
|
|
}
|
|
} // namespace test_unique_ptr
|