From 9944b743d042ebeff4761dff33cd7d636533aa93 Mon Sep 17 00:00:00 2001 From: Txema Ynzenga Date: Wed, 6 Dec 2023 16:05:25 +0100 Subject: [PATCH] Add rfl/internal/num_fields.hpp --- include/rfl/internal/has_n_fields.hpp | 1 + include/rfl/internal/num_fields.hpp | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 include/rfl/internal/num_fields.hpp diff --git a/include/rfl/internal/has_n_fields.hpp b/include/rfl/internal/has_n_fields.hpp index a4274fe5..5665a616 100644 --- a/include/rfl/internal/has_n_fields.hpp +++ b/include/rfl/internal/has_n_fields.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace rfl { namespace internal { diff --git a/include/rfl/internal/num_fields.hpp b/include/rfl/internal/num_fields.hpp new file mode 100644 index 00000000..10c47a17 --- /dev/null +++ b/include/rfl/internal/num_fields.hpp @@ -0,0 +1,28 @@ +#ifndef RFL_INTERNAL_NUM_FIELDS_HPP_ +#define RFL_INTERNAL_NUM_FIELDS_HPP_ + +#include + +#include "rfl/internal/has_n_fields.hpp" + +namespace rfl { +namespace internal { + +template +struct num_fields_impl { + static constexpr std::size_t value = num_fields_impl::value; +}; + +template + requires has_n_fields +struct num_fields_impl { + static constexpr std::size_t value = _n; +}; + +template +constexpr std::size_t num_fields = num_fields_impl::value; + +} // namespace internal +} // namespace rfl + +#endif