#ifndef RFL_INTERNAL_WRAP_IN_FIELDS_HPP_ #define RFL_INTERNAL_WRAP_IN_FIELDS_HPP_ #include #include #include "flattened_ptr_tuple_t.hpp" #include "is_flatten_field.hpp" #include "lit_name.hpp" namespace rfl { namespace internal { template auto wrap_in_fields(auto&& _tuple, Fields&&... _fields) { constexpr auto size = std::tuple_size_v>; constexpr auto i = sizeof...(_fields); if constexpr (i == size) { return std::make_tuple(std::move(_fields)...); } else { auto value = std::move(std::get(_tuple)); using Type = std::remove_cvref_t>; if constexpr (is_flatten_field_v) { // The problem here is that the FieldNames are already flattened, but this // is not, so we need to determine how many field names to skip. constexpr auto n_skip = std::tuple_size_v< std::remove_cvref_t>>; return wrap_in_fields( std::move(_tuple), std::move(_fields)..., std::move(value)); } else { const auto name_literal = FieldNames::template name_of(); auto new_field = rfl::make_field< lit_name_v>>( std::move(value)); return wrap_in_fields( std::move(_tuple), std::move(_fields)..., std::move(new_field)); } } } } // namespace internal } // namespace rfl #endif