#ifndef RFL_INTERNAL_NT_TO_PTR_NAMED_TUPLE_HPP_ #define RFL_INTERNAL_NT_TO_PTR_NAMED_TUPLE_HPP_ #include #include "../Field.hpp" #include "../make_named_tuple.hpp" namespace rfl { namespace internal { /// Generates a named tuple that contains pointers to the original values in /// the struct from a named tuple. template auto nt_to_ptr_named_tuple(NamedTupleType& _nt, AlreadyExtracted... _a) { using Fields = typename NamedTupleType::Fields; constexpr auto i = sizeof...(AlreadyExtracted); constexpr auto num_fields = std::tuple_size_v; if constexpr (i == num_fields) { return make_named_tuple(_a...); } else { using FieldType = typename std::tuple_element::type; using T = std::remove_cvref_t; return nt_to_ptr_named_tuple( _nt, _a..., Field(&std::get(_nt.values())) ); } } /// Generates a named tuple that contains pointers to the original values in /// the struct from a named tuple. template auto nt_to_ptr_named_tuple(const NamedTupleType& _nt, AlreadyExtracted... _a) { using Fields = typename NamedTupleType::Fields; constexpr auto i = sizeof...(AlreadyExtracted); constexpr auto num_fields = std::tuple_size_v; if constexpr (i == num_fields) { return make_named_tuple(_a...); } else { using FieldType = typename std::tuple_element::type; using T = std::remove_cvref_t; return nt_to_ptr_named_tuple( _nt, _a..., Field(&std::get(_nt.values())) ); } } } // namespace internal } // namespace rfl #endif