repr 0.1
Reconstructable string representations and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
aggregate.h
Go to the documentation of this file.
#pragma once
#include <cstddef>
#include <string>
#include <string_view>
#include <type_traits>
// TODO
#include "category.h"
#include "detail/arity.h"
namespace librepr {
template <typename T>
template <typename T>
struct Reflect;
namespace category {
template <typename Member, typename Parent, std::size_t Index>
struct DataMember : Member {
using descend = Member;
using type = typename Member::type;
using parent = Parent;
using parent_type = typename Parent::type;
using Member::visit;
};
} // namespace category
template <typename T>
requires(std::is_aggregate_v<T> && !(std::is_array_v<T> || has_custom_members<T> || detail::has_repr_member<T>))
struct Reflect<T> : category::Type<T> {
constexpr static auto member_count = librepr::detail::arity<T>;
using member_tuple = decltype(librepr::detail::to_reftuple(std::declval<T>()));
static_assert(!std::is_same_v<member_tuple, void>, "Aggregate reflection failed");
using type = T;
using members = typename member_types::template map<librepr::Reflect>;
constexpr static bool can_descend = true;
template <typename V>
static void visit(V&& visitor, T& obj) {
static_assert(members::size == decltype(decomposed)::size,
"Decomposed obj does not match reflected member amount.");
members::enumerate([&visitor, &decomposed]<typename M, std::size_t Index> {
});
}
template <typename V>
static void visit(V&& visitor) {
members::enumerate(
}
};
} // namespace librepr