diff --git a/include/avnd/common/struct_reflection.hpp b/include/avnd/common/struct_reflection.hpp index 884b9c9c..050c53a2 100644 --- a/include/avnd/common/struct_reflection.hpp +++ b/include/avnd/common/struct_reflection.hpp @@ -71,6 +71,21 @@ struct fields_introspection #endif } + template + static constexpr void for_all_n(type& fields, F&& func) noexcept + { +#if AVND_USE_BOOST_PFR + if constexpr(size > 0) + { + avnd::for_each_field_ref_n(fields, std::forward(func)); + } +#else + // FIXME pass it the avnd::field_index + auto&& [... elts] = fields; + (func(elts), ...); +#endif + } + static constexpr void for_nth(type& fields, int n, auto&& func) noexcept { // TODO maybe there is some dirty hack to do here with offsetof computations...