2024-05-31 22:59:00 -04:00
|
|
|
#ifndef RFL_INTERNAL_MOVE_FIELD_TUPLE_TO_NAMED_TUPLE_HPP_
|
|
|
|
#define RFL_INTERNAL_MOVE_FIELD_TUPLE_TO_NAMED_TUPLE_HPP_
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
#include "../Field.hpp"
|
|
|
|
#include "has_flatten_fields.hpp"
|
|
|
|
#include "move_and_flatten_field_tuple.hpp"
|
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace internal {
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
template <class FieldTuple>
|
|
|
|
auto move_field_tuple_to_named_tuple(FieldTuple&& _field_tuple) {
|
|
|
|
const auto ft_to_nt = []<class... Fields>(Fields&&... _fields) {
|
|
|
|
return make_named_tuple(std::move(_fields)...);
|
|
|
|
};
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
if constexpr (!has_flatten_fields<std::remove_cvref_t<FieldTuple>>()) {
|
|
|
|
return std::apply(ft_to_nt, std::move(_field_tuple));
|
|
|
|
} else {
|
|
|
|
auto flattened_tuple =
|
|
|
|
move_and_flatten_field_tuple(std::move(_field_tuple));
|
|
|
|
return std::apply(ft_to_nt, std::move(flattened_tuple));
|
|
|
|
}
|
|
|
|
}
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace rfl
|
2024-05-31 22:59:00 -04:00
|
|
|
|
|
|
|
#endif
|