draconisplusplus/include/rfl/named_tuple_t.hpp

42 lines
1.1 KiB
C++
Raw Normal View History

2024-05-31 22:59:00 -04:00
#ifndef RFL_NAMED_TUPLE_T_HPP_
#define RFL_NAMED_TUPLE_T_HPP_
#include <functional>
#include <tuple>
#include <type_traits>
#include "NamedTuple.hpp"
#include "internal/is_named_tuple.hpp"
#include "internal/ptr_named_tuple_t.hpp"
#include "internal/wrap_in_rfl_array_t.hpp"
#include "to_named_tuple.hpp"
namespace rfl {
2024-06-08 14:10:59 -04:00
template <class T>
struct remove_ptr;
template <internal::StringLiteral _name, class T>
struct remove_ptr<Field<_name, T>> {
2024-06-16 00:13:15 -04:00
using FieldType =
Field<_name, internal::wrap_in_rfl_array_t<std::remove_cvref_t<std::remove_pointer_t<T>>>>;
2024-06-08 14:10:59 -04:00
};
template <class T>
struct remove_ptrs_nt;
template <class... FieldTypes>
struct remove_ptrs_nt<NamedTuple<FieldTypes...>> {
2024-06-16 00:13:15 -04:00
using NamedTupleType = NamedTuple<typename remove_ptr<FieldTypes>::FieldType...>;
2024-06-08 14:10:59 -04:00
};
/// Generates the named tuple that is equivalent to the struct T.
/// This is the result you would expect from calling
/// to_named_tuple(my_struct). All fields of the struct must be an rfl::Field.
template <class T>
2024-06-16 00:13:15 -04:00
using named_tuple_t = typename remove_ptrs_nt<internal::ptr_named_tuple_t<T>>::NamedTupleType;
2024-06-08 14:10:59 -04:00
} // namespace rfl
2024-05-31 22:59:00 -04:00
#endif