#ifndef RFL_INTERNAL_MOVE_TO_FIELD_TUPLE_HPP_ #define RFL_INTERNAL_MOVE_TO_FIELD_TUPLE_HPP_ #include #include "../Tuple.hpp" #include "../field_names_t.hpp" #include "Array.hpp" #include "bind_to_tuple.hpp" #include "has_fields.hpp" #include "is_empty.hpp" #include "is_named_tuple.hpp" #include "wrap_in_fields.hpp" namespace rfl { namespace internal { template auto move_to_field_tuple(OriginalStruct&& _t) { using T = std::remove_cvref_t; if constexpr (is_named_tuple_v) { return _t.fields(); } else if constexpr (has_fields()) { return bind_to_tuple(_t, [](auto _ptr) { return std::move(*_ptr); }); } else if constexpr (is_empty()) { return rfl::Tuple(); } else { using FieldNames = field_names_t; const auto fct = [](T* _ptr) { using Type = std::remove_cvref_t; if constexpr (std::is_array_v) { return Array(*_ptr); } else { return std::move(*_ptr); } }; auto tup = bind_to_tuple(_t, fct); return wrap_in_fields(std::move(tup)); } } } // namespace internal } // namespace rfl #endif