Included the meta field retrieval

This commit is contained in:
Patrick Urbanke
2023-12-08 00:13:14 +01:00
parent 385f6434c5
commit 2c761efdcd
9 changed files with 128 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#include "test_meta_fields.hpp"
#include <iostream>
#include <rfl.hpp>
namespace test_meta_fields {
struct Person {
std::string first_name;
std::string last_name = "Simpson";
std::string town = "Springfield";
unsigned int age;
std::vector<Person> children;
};
void test() {
std::cout << std::source_location::current().function_name() << std::endl;
const auto fields = rfl::fields<Person>();
/*std::cout << "Fields in " << rfl::type_name_t<Person>().str() << ":"
<< std::endl;
for (const auto& f : fields) {
std::cout << "name: " << f.name() << ", type: " << f.type() << std::endl;
}*/
// The exact content is somewhat unpredictable, we just want to make sure it
// compiles.
if (fields.size() == 5) {
std::cout << "OK" << std::endl;
}
}
} // namespace test_meta_fields