Skip to content

Commit

Permalink
RECURSIVE -> RECURSIVE_DEPTH_FIRST_ORDER
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkaratarakis committed Aug 8, 2023
1 parent 6f9e852 commit 24224ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions include/fixed_containers/reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ constexpr void for_each_field_entry(const T& instance, Func func)
enum class RecursionType
{
NON_RECURSIVE,
RECURSIVE,
RECURSIVE_DEPTH_FIRST_ORDER,
};

template <RecursionType RECURSION_TYPE, typename T>
Expand All @@ -191,7 +191,7 @@ constexpr std::size_t field_count_of(const T& instance)
for_each_field_entry(instance,
[&counter](const FieldEntry& field_entry)
{
if (RECURSION_TYPE == RecursionType::RECURSIVE or
if (RECURSION_TYPE == RecursionType::RECURSIVE_DEPTH_FIRST_ORDER or
field_entry.enclosing_field_name().empty())
{
++counter;
Expand All @@ -214,7 +214,7 @@ constexpr auto field_info_of(const T& instance) -> FixedVector<FieldEntry, MAXIM
for_each_field_entry(instance,
[&output](const FieldEntry& field_entry)
{
if (RECURSION_TYPE == RecursionType::RECURSIVE or
if (RECURSION_TYPE == RecursionType::RECURSIVE_DEPTH_FIRST_ORDER or
field_entry.enclosing_field_name().empty())
{
output.push_back(field_entry);
Expand Down
8 changes: 5 additions & 3 deletions test/reflection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ constexpr std::string_view pick_compiler_specific_string([[maybe_unused]] const
TEST(Reflection, DebuggingHelper)
{
using enum reflection_detail::RecursionType;
auto foo = reflection_detail::field_info_of<RECURSIVE, MyColors>();
auto foo = reflection_detail::field_info_of<RECURSIVE_DEPTH_FIRST_ORDER, MyColors>();
// std::cout << foo.size() << std::endl;
(void)foo;
}
Expand Down Expand Up @@ -128,9 +128,11 @@ TEST(Reflection, RecursiveExample)
using enum reflection_detail::RecursionType;

static_assert(
consteval_compare::equal<10, reflection_detail::field_count_of<RECURSIVE, MyColors>()>);
consteval_compare::
equal<10, reflection_detail::field_count_of<RECURSIVE_DEPTH_FIRST_ORDER, MyColors>()>);

constexpr auto FIELD_INFO = reflection_detail::field_info_of<RECURSIVE, MyColors>();
constexpr auto FIELD_INFO =
reflection_detail::field_info_of<RECURSIVE_DEPTH_FIRST_ORDER, MyColors>();

static_assert(FIELD_INFO.at(0).field_type_name() == "int");
static_assert(FIELD_INFO.at(0).field_name() == "yellow");
Expand Down

0 comments on commit 24224ad

Please sign in to comment.