#ifndef RFL_INTERNAL_REMOVEFIELDS_HPP_ #define RFL_INTERNAL_REMOVEFIELDS_HPP_ #include #include #include #include "../NamedTuple.hpp" #include "../define_named_tuple.hpp" #include "StringLiteral.hpp" namespace rfl { namespace internal { /// Recursively builds a new NamedTuple type from the FieldTypes, leaving /// out the field signified by _name. template struct remove_single_field; /// Special case - _i == 0 template struct remove_single_field<_OldNamedTupleType, _name, _NewNamedTupleType, 0> { using type = _NewNamedTupleType; }; /// General case. template struct remove_single_field { using OldNamedTupleType = std::remove_cvref_t<_OldNamedTupleType>; constexpr static int num_fields = std::tuple_size_v; using FieldType = std::remove_cvref_t< typename std::tuple_element::type>; using NewNamedTupleType = std::conditional_t< _name == FieldType::name_, _NewNamedTupleType, define_named_tuple_t<_NewNamedTupleType, FieldType>>; using type = typename remove_single_field::type; }; /// Recursively removes all of the fields signified by _head and _tail from /// the NamedTupleType. template struct remove_fields; /// Special case - only head is left. template struct remove_fields<_NamedTupleType, _head> { using NamedTupleType = std::remove_cvref_t<_NamedTupleType>; constexpr static int num_fields = std::tuple_size_v; using type = typename remove_single_field, num_fields>::type; }; /// General case. template struct remove_fields { using NamedTupleType = std::remove_cvref_t<_NamedTupleType>; constexpr static int num_fields = std::tuple_size_v; using NewNamedTupleType = typename remove_single_field, num_fields>::type; using type = typename remove_fields::type; }; } // namespace internal } // namespace rfl #endif // RFL_REMOVEFIELDS_HPP_