1#ifndef CODEX_REFLECTION_SOA_HPP
2#define CODEX_REFLECTION_SOA_HPP
22template<
typename T,
typename S = detail::storage_descriptor>
28 template<std::
size_t I>
30 std::decay_t<std::tuple_element_t<I, field_tuple_t<T>>>;
42 void set(std::size_t i,
const T &
t);
46 template<std::
size_t I> std::span<field_type<I>>
field(
void);
47 template<std::
size_t I> std::span<const field_type<I>>
field(
void)
const;
50template<
typename T,
typename S>
53 this->for_each_i(i, [
t =
field_tuple(ret)](
auto fi,
auto &
x) {
54 std::get<fi()>(
t) =
x;
59template<
typename T,
typename S>
61 using detail::field_storage;
62 this->for_each([&
t]<
typename F, std::size_t I>(field_storage<S, I, F> &v) {
67template<
typename T,
typename S>
69 this->for_each_i(i, [&
t](
auto vi,
auto &
x) {
74template<
typename T,
typename S>
76 this->for_each_i(i, [&
t](
auto vi,
auto &
x) {
81template<
typename T,
typename S>
82template<std::
size_t I>
84 using F = field_type<I>;
85 return *
static_cast<detail::field_storage<S, I, F>*
>(
this);
88template<
typename T,
typename S>
89template<std::
size_t I>
91 using F = field_type<I>;
92 return *
static_cast<const detail::field_storage<S, I, F>*
>(
this);
Transparently stores T objects as contiguous arrays of each field.
Definition soa.hpp:23
T operator[](std::size_t i) const
Indexed access to an element.
std::decay_t< std::tuple_element_t< I, field_tuple_t< T > > > field_type
(Value/decayed) type of field with index I.
Definition soa.hpp:29
std::size_t size(void) const
Definition soa.hpp:32
std::span< const field_type< I > > field(void) const
void set(std::size_t i, const T &t)
Stores the value of each field of t.
void set(std::size_t i, T &&t)
Stores the value of each field of t.
std::span< field_type< I > > field(void)
Provides access to the contiguous storage of field I.
#define x
Definition gcc14.c:1
constexpr codex::vec3 v
Definition rotate_test.cpp:12
auto field_tuple(T &&t)
Constructs a tuple of references to each field of T, in order.
Definition fields.hpp:35
codex::refl::field_tuple_t< E > T
Definition soa.cpp:9
#define CODEX_FWD(x)
Definition utils.hpp:8
#define t(a)
Definition std2.c:10