diff --git a/include/rfl/internal/get_field_names.hpp b/include/rfl/internal/get_field_names.hpp index f21698eb..df0a2b97 100644 --- a/include/rfl/internal/get_field_names.hpp +++ b/include/rfl/internal/get_field_names.hpp @@ -115,7 +115,9 @@ with open("generated_code5.cpp", "w", encoding="utf-8") as codefile: template auto get_field_names() { - if constexpr (has_n_fields) { + if constexpr (std::is_pointer_v>) { + return get_field_names>(); + } else if constexpr (has_n_fields) { return std::array{}; } else if constexpr (has_n_fields) { auto& [f1] = fake_object; diff --git a/tests/json/test_box.hpp b/tests/json/test_box.hpp index 4c35cbe6..3e72b202 100644 --- a/tests/json/test_box.hpp +++ b/tests/json/test_box.hpp @@ -12,14 +12,14 @@ namespace test_box { struct DecisionTree { struct Leaf { using Tag = rfl::Literal<"Leaf">; - rfl::Field<"value", double> value; + double value; }; struct Node { using Tag = rfl::Literal<"Node">; - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", rfl::Box> lesser; - rfl::Field<"right", rfl::Box> greater; + rfl::Rename<"criticalValue", double> critical_value; + rfl::Box lesser; + rfl::Box greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -43,6 +43,6 @@ void test() { write_and_read( tree, - R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"lesser":{"leafOrNode":{"type":"Leaf","value":3.0}},"greater":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } } // namespace test_box diff --git a/tests/json/test_ref.hpp b/tests/json/test_ref.hpp index 8d24820c..c6929241 100644 --- a/tests/json/test_ref.hpp +++ b/tests/json/test_ref.hpp @@ -12,14 +12,14 @@ namespace test_ref { struct DecisionTree { struct Leaf { using Tag = rfl::Literal<"Leaf">; - rfl::Field<"value", double> value; + double value; }; struct Node { using Tag = rfl::Literal<"Node">; - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", rfl::Ref> lesser; - rfl::Field<"right", rfl::Ref> greater; + rfl::Rename<"criticalValue", double> critical_value; + rfl::Ref lesser; + rfl::Ref greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -43,6 +43,6 @@ void test() { write_and_read( tree, - R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"lesser":{"leafOrNode":{"type":"Leaf","value":3.0}},"greater":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } } // namespace test_ref diff --git a/tests/json/test_unique_ptr2.hpp b/tests/json/test_unique_ptr2.hpp index 7beadf4c..8263afa5 100644 --- a/tests/json/test_unique_ptr2.hpp +++ b/tests/json/test_unique_ptr2.hpp @@ -12,14 +12,14 @@ namespace test_unique_ptr2 { struct DecisionTree { struct Leaf { using Tag = rfl::Literal<"Leaf">; - rfl::Field<"value", double> value; + double value; }; struct Node { using Tag = rfl::Literal<"Node">; - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", std::unique_ptr> lesser; - rfl::Field<"right", std::unique_ptr> greater; + rfl::Rename<"criticalValue", double> critical_value; + std::unique_ptr lesser; + std::unique_ptr greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -43,6 +43,6 @@ void test() { write_and_read( tree, - R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"lesser":{"leafOrNode":{"type":"Leaf","value":3.0}},"greater":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } } // namespace test_unique_ptr2