mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
Added more features to the automated field name retrieval
This commit is contained in:
@@ -7,19 +7,21 @@
|
||||
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
void test_string_unordered_map() {
|
||||
std::cout << "test_string_unordered_map" << std::endl;
|
||||
namespace test_string_unordered_map {
|
||||
void test() {
|
||||
std::cout << "test_string_unordered_map" << std::endl;
|
||||
|
||||
using Map = std::unordered_map<std::string, std::unique_ptr<std::string>>;
|
||||
Map homer;
|
||||
homer.insert(
|
||||
std::make_pair("firstName", std::make_unique<std::string>("Homer")));
|
||||
homer.insert(
|
||||
std::make_pair("lastName", std::make_unique<std::string>("Simpson")));
|
||||
using Map = std::unordered_map<std::string, std::unique_ptr<std::string>>;
|
||||
Map homer;
|
||||
homer.insert(
|
||||
std::make_pair("firstName", std::make_unique<std::string>("Homer")));
|
||||
homer.insert(
|
||||
std::make_pair("lastName", std::make_unique<std::string>("Simpson")));
|
||||
|
||||
// Unordered maps are unpredictable. We therefore only make sure that this
|
||||
// compiles.
|
||||
const auto json_string = rfl::json::write(homer);
|
||||
const auto homer2 = rfl::json::read<Map>(json_string);
|
||||
std::cout << "OK" << std::endl << std::endl;
|
||||
// Unordered maps are unpredictable. We therefore only make sure that this
|
||||
// compiles.
|
||||
const auto json_string = rfl::json::write(homer);
|
||||
const auto homer2 = rfl::json::read<Map>(json_string);
|
||||
std::cout << "OK" << std::endl << std::endl;
|
||||
}
|
||||
} // namespace test_string_unordered_map
|
||||
|
||||
Reference in New Issue
Block a user