add rfl::get_enumerators() and rfl::get_enumerator_array()

This commit is contained in:
stu
2024-02-22 15:24:20 +00:00
parent a1fb54f4ac
commit c76e7a6471
4 changed files with 64 additions and 1 deletions
+8
View File
@@ -35,6 +35,14 @@ void test() {
Circle{.radius = 2.0, .color = Color::blue | Color::orange};
write_and_read(circle, R"({"radius":2.0,"color":"red|blue|yellow"})");
auto mutable_circle = circle;
rfl::get_enumerators<Color>().apply([&](auto field) {
if constexpr (decltype(field)::name() == "green") {
mutable_circle.color = field.value();
}
});
write_and_read(mutable_circle, R"({"radius":2.0,"color":"green"})");
}
} // namespace test_flag_enum